Complicated Math question

Post any maths and/or physics related questions here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Complicated Math question

Postby OgreCoder » Fri Dec 17, 2004 7:07 am

I have an extremely complicated math question. I have a function that can transform the difference in latitude and longitude of two points into a distance in feet. It is a WGS84 to XY conversion. (WGS84 is the coordinate system used to measure lat and lon). This all works well. The thing is I want to be able to reverse it. I will know my starting lat and lon and how far away I want to go in feet, and then find out the lat and lon of the new point. Here is my function:

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.
Friends don't let friends use IE.

Firefox for all
User avatar
OgreCoder
 
Posts: 398
Joined: Fri Oct 01, 2004 1:52 pm
Location: Washington D.C.

Postby Darryl » Fri Dec 17, 2004 8:37 am

I will know my starting lat and lon and how far away I want to go in feet, and then find out the lat and lon of the new point.

You will also need a direction.

Darryl
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands


Return to Maths & Physics

Who is online

Users browsing this forum: No registered users and 1 guest