D
ok, habs hinbekommen
struct SPoint
{
double x;
double y;
operator CPoint()
{
return CPoint((int)x,(int)y);
}
bool operator==(const SPoint &p)
{
return x==p.x&&y==p.y;
}
};
struct SVector
{
double X;
double Y;
};
struct SElectron
{
SPoint Pos;
SVector Velocity;
};
const double ScaleFactor = 1.0;
const double e = 1.6e-19;
const double m = 9.1e-31;
const double edivm = e/m; // e/m = 1.6*10^-19 C / 9.1*10^-31 kg
double DeltaT1(double v,double F)
{
double tmp = sqrt(pow(v,2)+(4.0*F*m));
double tmp2 = -v+tmp;
return tmp2/(2.0*F);
}
void CalcNewElectronPosition(SElectron *pElectron, float fB,float fU,float fR)
{
double deltaT = 1e-9;
double dFLY = e*fB*pElectron->Velocity.X - e*fU/fR;
pElectron->Velocity.Y+=(dFLY/m*deltaT);
double dFLX = e*fB*(-pElectron->Velocity.Y);
pElectron->Velocity.X+=(dFLX/m*deltaT);
double dFL = sqrt(dFLX*dFLX+dFLY*dFLY);
double dV = sqrt(pElectron->Velocity.X*pElectron->Velocity.X+pElectron->Velocity.Y*pElectron->Velocity.Y);
pElectron->Pos.x+=(pElectron->Velocity.X*deltaT)/0.00025;
pElectron->Pos.y+=(pElectron->Velocity.Y*deltaT)/0.00025;
}
void Plot(CDC *pDC, float fUb, float fB, float fU, float fR)
{
SElectron e;
e.Pos.x=100;
e.Pos.y=150;
e.Velocity.X=sqrt(2.0*edivm*(double)fUb);
e.Velocity.Y=0;
int i=0;
SPoint OldPos;
pDC->Arc(CRect(50,50,150,150),CPoint(100,150),CPoint(100,51));
while(i++<1000)
{
CalcNewElectronPosition(&e,fB,fU,fR);
if(!(e.Pos==OldPos)&&e.Pos.x>100&&e.Pos.x<300&&e.Pos.y>50&&e.Pos.y<250)
{
OldPos=e.Pos;
pDC->SetPixel(e.Pos,RGB(255,0,0));
}
}
}
Es ist defacto immer noch eine Spirale. Aber so nah am Kreis, dass es (a) nicht stört und dass man es (b) nicht bemerkt