Jump to content
The simFlight Network Forums

Seppel2000and3

Members
  • Posts

    3
  • Joined

  • Last visited

About Seppel2000and3

  • Birthday 01/01/1970

Contact Methods

  • Website URL
    http://

Seppel2000and3's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. 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
  2. Hi, hmmpf, im getting crazy ;-) Thank you for your answer, but one answer = lots of new questions ;-) 1.) i compute the distance with this: double dDst = acos(sin(dMyLat) * sin(dAiLat) + cos(dMyLat) * cos(dAiLat) * cos(dMyLon - dAiLon)); do i have first the Lat and Lon values turn into RAD??? with (dMyLat/180 * PI) or something else? 2.) the magvar im getting from FSUIPC (long int), i have to recalculate it with something before i give it to my function? like this: db_own_magvar = (double)li_own_magvar * (360/65536); 3.) before return dHdg; i have to convert it to another format (RAD/DEG/360/PI or something else) Here is a short table from values you have in TrafficLook and i have: yours|mine 181|136.175 103|98.7678 179|136.144 271|270.908 152|129.048 346|313.924 Thats not very near the values you have ;-) Thanks for your answers, Sebastian
  3. Hi, i tried the whole night, to calculate the bearing from to points in given format (dd.mmmm) I tried several things but didnt received the same result as in TrafficLook. I'm programming in C++, and if somebody can give me a hint i would be more happy than now. I hope its ok, when i post my last try here: - Lat1&Lon1 are my aircraft position from the offset described in the SDK - Lat2&Lon2 are the AI Aircraft position from the TCAS Data described in the SDK - The value for distance is okay, so it must be a fault with the bearing algorithm double Bearing(double Lat1, double Lon1, double Lat2, double Lon2) { double B1 = Lat1/180 * PI; //DEG to RAD double B2 = Lat2/180 * PI; double L1 = Lon1/180 * PI; double L2 = Lon2/180 * PI; double t1,t2,t3,t4,t5; double rad_bearing; double rad_dist = acos(sin(B1) * sin(B2) + cos(B1) * cos(B2) * cos(L1 - L2)); if (sin (L2 - L1) < 0.0) { t1 = sin(B2) - sin(B1) * cos(rad_dist); t2 = cos(B1) * sin(rad_dist); t3 = t1 / t2; t4 = atan(-t3 / sqrt(-t3 * t3 + 1)) + 2 * atan(1); rad_bearing = t4; } else { t1 = sin(B2) - sin(B1) * cos(rad_dist); t2 = cos(B1) * sin(rad_dist); t3 = t1 / t2; t4 = -t3 * t3 + 1; t5 = 2 * 3.14 - (atan(-t3) / sqrt(-t3 * t3 + 1)) + 2 * atan(1); rad_bearing = t5; } double BG = rad_bearing * 57.2957795; return BG; } Two hours ago, i tried another source (from an website) this gave me some values that were somehow in relationship with the values in TrafficLook. But they were always too small?!? I can post that later, if somebody wants ;-) OK, last word: Sorry for my bad english... Hope for good answers, Sebastian
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.