Moderator: Mod Squad
True Order wrote:I truly hate trying to program.
#include <vcl.h>
#pragma hdrstop
#include "Start.h"
#include "Okno.h"
#include <math.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TOkno Okno;
vector<WK2> P;
vector<double> A,B;
double T=1;
int N=0;
double TransF(double t)
{
double result=0;
int N=A.size();
if(N>0)
result=A[0]/2;
for(int j=1;j<N;j++)
{
result+=A[j]*cos(j*2*M_PI/T*t)+B[j]*sin(j*2*M_PI/T*t);
}
return result;
}
// --------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
Okno.Inicjuj(PaintBox);
Okno.Skala(-1,8,-1.5,1.5);
P.resize(10); //for(int i=0; i<(int)P.size(); i++)P[i]=WK2(0.5*i,sin(0.5*i));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBoxMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if(Shift.Contains(ssCtrl)) Okno.SkalaMouseDown( Shift, X, Y);
else if(Shift.Contains(ssAlt)) Okno.ZmienPunkt ( X,Y,0, P);
else if(Shift.Contains(ssShift)) Okno.UsunWstawPunkt(X,Y ,P);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBoxMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if(Shift.Contains(ssCtrl)) Okno.SkalaMouseMove( Shift, X, Y);
else if(Shift.Contains(ssAlt)) Okno.ZmienPunkt ( X,Y,1, P);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBoxMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Okno.ZmienPunkt ( X,Y,2, P);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBoxPaint(TObject *Sender)
{
Okno.Czysc();
Okno.Siatka();
Okno.Osie();
Okno.Punkty( P, clGreen);
Okno.Funkcja(TransF,clBlue);
Okno.Rysuj();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton1Click(TObject *Sender)
{
for(int i=1;i<N;i++)
{
A[i]=0;
B[i]=1;
}
PaintBoxPaint(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton2Click(TObject *Sender)
{
for(int i=1;i<N;i++)
{
A[0]=T;
A[i]=0;
B[i]=-T/M_PI/i;
}
PaintBoxPaint(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton3Click(TObject *Sender)
{
for(int i=1;i<N;i++)
{
A[0]=0;
A[i]=0;
if(i%2==0)
B[i]=0;
else if(i%2!=0)
B[i]=T/i/M_PI;
}
PaintBoxPaint(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton4Click(TObject *Sender)
{
for(int i=1;i<N;i++)
{
A[0]=T;
A[i]=0;
B[i]=T/M_PI/i;
}
PaintBoxPaint(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton5Click(TObject *Sender)
{
for(int i=1;i<N;i++)
{
A[0]=0;
A[i]=0;
if(i%2==0)
B[i]=0;
else if(i%2!=0)
B[i]=(8/M_PI/M_PI/i/i)*pow(-1,(i-1)/2);
}
PaintBoxPaint(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton6Click(TObject *Sender)
{
for(int i=1;i<N;i++)
{
A[0]=0.5*M_PI*T;
A[i]=(-T*T)/(M_PI*M_PI*i*i);//(pow(-1,i)*T*M_PI)/i;
B[i]=0;
}
PaintBoxPaint(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ScrollBar3Change(TObject *Sender)
{
N=ScrollBar3->Position;
Label3->Caption=String("N = ") + ScrollBar3->Position;
A.resize(N);
B.resize(N);
PaintBoxPaint(Sender);
}
//---------------------------------------------------------------------------
Q.U. wrote:...greek...
True Order wrote:I truly hate trying to program.
I tried a class once and did not last a week, it wasn't the grades that got me it was.... the insanity that stemmed from it. You know the one. The kind that makes you think you can't win no matter what. One problem is fixed and several others replace it.And that these problems can happen for no discernible reason.
Another way machine rebels against man.
Return to Wham, Spam, Thank you, Ma'am!
Users browsing this forum: Google [Bot], Jesturr and 3 guests