Jump to content

Sign in to follow this  
Guest lmoelleb

Calculating distance between geographic points

Recommended Posts

Guest lmoelleb

Hi,I am fooling around with a small utility where I need to calculate the distance between two geographic points giving the latitude and longitude. More precisely I am trying to calculate the point at a given distance from the reference point. I am using the following formula, but my test shows that it is something like 10% off the size:longitude.Radian += distance.X / ((40075000.0 / (2.0 * Math.PI)) * Math.Cos(Latitude.Radian));latitude.Radian += distance.Y / (40007000.0 / (2.0 * Math.PI));I am aware that you should normally try to use the latitude between the two points, but my base point is always the center of the object, so I should be fine - and nothing will be bigger than 1km anyway.Does anyone have the correct parameters to use with Flight Simulator? I got these of the SDK but probably misunderstood one or another thing. My current formula use meters, but if I get something else, I think it is within my limits to convert it to meters (after all, I do not work for NASA). :)/Lars

Share this post


Link to post
Share on other sites
Guest JohnC

Lars, I can't remember the spherical geometry formula for the distance between two points, but I DO remember there were a number of terms which contained the sines of angles VERY close to 0 with numbers like 0.00000000000001265 and the cos of angles VERY close to 1 like 0.9999999999749. Very small angles are subtended for most practical purposes when measuring small distances on the surface.So unless you use (VBA?) code which accomodates a very large number of decimal points, the final values will be off by a significant percentage.I assume you need real precision here that works across the whole planet.......:-bluegrab

Share this post


Link to post
Share on other sites
Guest JohnC

This guy Williams must sleep with a globe beside his bed.........his paper was the one I used to transport the formula to Excel but found that small distances were not accurate...or at least they didn't agree with MicroSoft Streets and Trips.

Share this post


Link to post
Share on other sites
Guest lmoelleb

Hmm, strange I managed to avoid that thread when searching, I must have typed wrong in the search :)As far as I can see, this formula is close to what I am having, except I tried to use the values of the SDK, so that might be the problem.I use the .Net framework so if needed I can use the decimal calss, but a double should do the trick. Notice that only one COS is used based on the latitude (not the distance between the points) so it should be fine.Thanks for the help, I will move on when time allows (long weekend coming up, so there is hope). Worst case I will just do some "reverse" calculation to find the required numbers, whatever they might be. :)/Lars

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...