1

I do not want any code but want to get reference that how can we find the angle between two locations defined by Latitude or Longitude...

If you do have reference then Please help me to solve my problem...

Thanx in advance....

Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94

3 Answers3

7

The formula to calculate bearing is:

θ = atan2( sin(Δlong).cos(lat2), cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong) )

Bearing is a direction to move from one location to another location (starting from north and then clockwise). While angle in 2D starts from the east and then counter clockwise. So if an angle is what you need, later you'll need to add 90 degree to the result and then revert it (add minus).

Reference: http://www.movable-type.co.uk/scripts/latlong.html

1

try the Atan method

Math.Atan2(x1-x2,y1-y2)            
dknaack
  • 60,192
  • 27
  • 155
  • 202
  • x1 is the x coordinate of point 1, x2 is the x cordinate of point 2 and so on.. ok ? So in you case (geolocation) x1 is the longitude of the first location. – dknaack Jul 19 '11 at 09:44
  • means x1 is first Latitude and y1 is first longitude and so on like this? – Mehul Mistri Jul 19 '11 at 09:46
0

Try this website, it does all the calculations for you. Whereas the formulas, those can be found on wiki or any other sites. I like this site cos it managed to help me settle a lot of problems. And even if this web tool was developed in San Francisco, even I am from Singapore. This will work.

Latitude and Longitude web tool

Melvin Lai
  • 861
  • 3
  • 17
  • 35