- Code: Select all
WGS84_to_XY(double curLat, double curLon, double origLat, double origLon,
double &x, double &y)
double coslat, sinlat, deltaLat, deltaLon, smallLat;
deltaLon = origLon - curLon;
deltaLat = curLat - origLat;
if (fabs(origLat) > fabs(curLat))
smallLat = origLat;
smallLat = curLat;
coslat = cos(smallLat*M_PI/180); //M_PI is 3.14159....
sinlat = sin(smallLat*M_PI/180);
x = -20925646.99508*(deltaLon*M_PI/180)*coslat*
y = 20890581.85603409*(deltaLat*M_PI/180)
Even if I can get it to relatively good accuracy it would be helpful. This info came from inforamtion on the web. I essentially will have x, y, origLat, origLon. I want to solve for curLat, curLon. Lat is a lot easier to solve for. Just taking the circumference of the earth, about 24,859.82 miles, and divide by 360 degrees and you know how far one degree of latitude equals in miles. So essenentially all I need now is curLon, as I can caculate curLat. Thanks.