请高手帮忙看下,这段程序有没有什么错误(只看下画图的那几个命令和逻辑)?为什么我运行完之后最大或者最小窗口之后,曲线就完全变了呢?
void CAmtdraw3View::OnDraw(CDC* pDC)
{
struct in
{
double phi;
int zd;
}amtin;
static struct out
{
double alpha;
double ne;
double nc;
double va;
double xc;
double t;
} amtout={0,1000,0,0,0.01183,0};
static struct control
{
double ut;
double uc;
double ux;
double uh;
int state;
int gearnum;
}amtcontrol={0,0,0,0,0,1};
int n;
double tx,th;
CAmtdraw3Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->MoveTo(0,20);
for (n=1;n<=400;n++)
{
if(n<=100)
amtin.phi=0.6*n*T;
else if(n<=1000)
amtin.phi=0.8;
else if(n<1500)
amtin.phi=0.6+0.04*n*T;
else amtin.phi=1.2;
amtin.zd=0;
amtcontrol.state=stateFunction(amtcontrol.gearnum,amtout.alpha,amtout.va,amtout.xc);
amtcontrol.ut=throttlecontrol(amtin.phi,amtout.alpha,amtout.va,amtout.ne,amtcontrol.gearnum,amtcontrol.state);
amtcontrol.uc=clutchcontrol(amtcontrol.state,amtout.xc,amtout.ne,amtout.nc,amtout.va,amtin.phi,amtin.zd);
amtcontrol.ux=xuandangctrl(amtcontrol.state);
tx=xuandang(amtcontrol.state,amtcontrol.ux,amtcontrol.gearnum,amtout.va);
amtcontrol.uh=huandangctrl(amtcontrol.state);
th=huandang(amtcontrol.state,amtout.nc,amtcontrol.gearnum,amtcontrol.uh,n);
amtout.t=tx+th;
amtout.xc=xcFunction(amtcontrol.uc,n);
amtcontrol.gearnum=gearnumFunction(amtcontrol.state,amtout.va,amtout.t);
amtout.alpha=throttle(amtcontrol.ut);
amtout.ne=neFunction(amtcontrol.gearnum,amtcontrol.uc,amtout.va,amtout.nc,amtout.alpha,amtout.xc);
amtout.nc=ncFunction(amtcontrol.gearnum,amtout.va,amtout.ne,amtout.xc);
amtout.va=vaFunction(amtcontrol.state,amtcontrol.ux,amtcontrol.uh,amtcontrol.gearnum,amtout.nc,amtout.xc);
CPen penRed(PS_SOLID,1,RGB(255,0,0)) ;
CPen *pOldPen=NULL;
pOldPen=pDC->SelectObject(&penRed);
pDC->LineTo(n,(int)amtout.ne/50);
}
}