设定了变量值自动更新,程序跑的过程中有的值变化,有的值显示“cannot evaluate”,如图,这个是怎么回事?(变量声明见代码,在同一个函数)
代码:
void Coordinate_Compute()
{
double X_Now = 0; //current coordinate
double Y_Now = 0; //current coordinate
double latitude_temp = 0;
double latitude_cur = 0;
double C1,C2,C3,C4,C5,C6; //middle value
double C = 0; //middle value
// double Latitude_Per=40075.04/360; //the distance of per latitude
float R = 6371.004; //radius of earth(km)
float Pi = 3.141593; //PI
double Distance = 0; //result of compute
C1 = C2 = C3 = C4 = C5 = C6 = C; //init middle value
latitude_cur = (double)gpsx.latitude;
latitude_temp = latitude_cur - Latitude_Set;
X_Now = R * (latitude_temp) / (2 * Pi * 1000);//update the X_Now ,m
// C=sin((Latitude_Set/100000))*sin((gpsx.latitude/100000))+cos((Longitude_Set/100000-gpsx.longitude/100000))*cos((Longitude_Set/100000))*cos((gpsx.longitude/100000));
// C=sin()*sin()+cos()*cos()*cos();
// the value of C is WRONG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
C1 = (Latitude_Set / 100000);
C2 = (Latitude_Now / 100000);
C3 = Longitude_Set / 100000 - Longitude_Now / 100000;
C4 = (Latitude_Set / 100000);
C5 = (Latitude_Now / 100000);
C = sin(C1) * sin(C2) + cos(C3) * cos(C4) * cos(C5);
/////////////////////////////////////////////////////////////////////
Distance = R * acos(C) * Pi * 1000 / 180; //m
C6 = pow(Distance,2) - pow(X_Now,2);
Y_Now = sqrt(C6);
if(X_Now < 0)
{
LCD_ShowString(120,150,20,16,16,"-");
X_Now = - X_Now;
}
else LCD_ShowString(150,150,20,16,16," ");
if(Longitude_Set - ((double)gpsx.longitude) > 0)
{
LCD_ShowString(140,170,20,16,16,"-");
Y_Now = Y_Now;
}
else LCD_ShowString(150,170,20,16,16," ");
LCD_ShowxNum(150,150,X_Now,5,16,0);
LCD_ShowxNum(150,170,Y_Now,5,16,0);
LCD_ShowxNum(150,190,Distance,5,16,0);
}
|