Given: Latitude/Longitude/Bearing/Distance, Where am I?

Started by
11 comments, last by RonHiler 15 years, 8 months ago
Quote:Original post by ilmarinen
Bearing:
0 -> You're heading north
+pi/2 -> You're heading west
-pi/2 -> You're heading east
(+/-)pi -> You're heading south

Hmmm, my bearings range from 0->2pi, and they seem to work based on my tests (a bearing of pi/2 is east, a bearing of 3pi/2 is west), but otherwise I am set up the way you describe. My latitudes run from pi/2 (North pole) to -pi/2 (south pole) with 0 at the equator. My longitudes run from 0 to 2pi. And everything seems to go the right direction when I run them through the equations :)

You guys have convinced me that nothing is wrong, I freaked out over nothing, heh. Thanks.

One last question before I put this to bed. From time to time I get a value out of range. For the most part, the equations handle wrapping on their own, but every once in a while I get a result for the end longitude that is over 2pi. For example, this one:

Start Lat: 1.29554
Start Long: 4.95131
Bearing: 0
Distance: 50

End Lat: 1.53925
End Long: 8.0929

This seems to happen only when I start or end near the north pole (south pole doesn't seem to have the same problem). Is this just a rounding issue? Do you think I can just do a -2pi on the value and call it good if it ends up out of range?

So far I haven't been able to get the latitude to go out of range, or the longitude to go below range, only over it. But it may be I haven't tested it enough to hit those cases.
Creation is an act of sheer will
Advertisement
since asin can result in values between −π/2 ≤ x ≤ π/2, latitude can't go beyond range.
The longitude can, since an addition is made. But you should fine if you move it back into range when necessary.
Quote:Original post by ilmarinen
since asin can result in values between −π/2 ≤ x ≤ π/2, latitude can't go beyond range.
The longitude can, since an addition is made. But you should fine if you move it back into range when necessary.


Ah, good point, I should have seen that. Thanks, I think I am satisfied. Time to move on to the next item on the list.

Thanks a lot guys. As always, you've been a huge help to me.

Creation is an act of sheer will

This topic is closed to new replies.

Advertisement