- 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;
else
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*
(1/sqrt(1-0.00669437999014*sinlat*sinlat));
y = 20890581.85603409*(deltaLat*M_PI/180)
-(52619.77967973982*sin(2*deltaLat*M_PI/180))
+(55.22375743665538*sin(4*deltaLat*M_PI/180))
-(0.0715248258209759*sin(6*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.
