Hi,
sorry i ask again, but this seems to be a very hard nut for me ;-)
Im standing on EDDF (have a HDG of 111). Now my question, is -214 a good value for the MagVar??? What is the MagVar?
Sorry, im posting again my try:
___MAIN.CPP___
TCAS_DATA slots[20]; // i know i can realize that with a list, but for testing its ok
short int siMagVar;
__int64 liMyOwnLat, liMyOwnLon;
double dMyOwnLat, dMyOwnLon;
//... getting datas from FSUIPC, then convert to degrees
dMyOwnLat = liMyOwnLat * (90.0/(10001750.0 * 65536.0 * 65536.0));
dMyOwnLon = liOwnLon * (360.0/(65536.0 * 65536.0 * 65536.0 * 65536.0));
Bearing(dMyOwnLat,dMyOwnLon,slots[0].lat,slots[0].lon,siMagVar);
___MyTCAS.CPP___
double Bearing(double dMyLat, double dMyLon, double dAiLat, double dAiLon, short int MagVar)
{
double dHdg; // result in degrees
double rad_dMyLat = (dMyLat * PI) / 180.0; // User Latitude converts to RAD
double rad_dMyLon = (dMyLon * PI) / 180.0; // User Longitude converts to RAD
double rad_dAiLat = (dAiLat * PI) / 180.0; // AI Latitude converts to RAD
double rad_dAiLon = (dAiLon * PI) / 180.0; // AI Longitude converts to RAD
double rad_dDst = acos(sin(rad_dMyLat) * sin(rad_dAiLat) + cos(rad_dMyLat) * cos(rad_dAiLat) * cos(rad_dMyLon - rad_dAiLon));
dHdg = (dMyLat == dAiLat) ? 90.0 : (180.0 * atan(fabs(rad_dDst/(rad_dAiLat-rad_dMyLat))) / PI);
if (dMyLat >= dAiLat) {
if (dMyLon >= dAiLon) dHdg += 180.0;
else dHdg = 180.0 - dHdg; }
else if (dMyLon > dAiLon)
dHdg = 360.0 - dHdg;
// correct for magvar
dHdg -= ((MagVar * 360.0) / 65536.0);
if (dHdg < 0.0) dHdg += 360.0;
if (dHdg > 360.0) dHdg -= 360.0;
//dHdg = (dHdg * 180) / PI; //(rad to deg);
return dHdg;
}
Im very confused about this RAD and DEG things, but i need this Bearingvalue realy, want to implement a nice radar.
I know im on the first mile of a marathon, but i like to do this ;-)
Thanks for your great help, Sebastian