Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate angle between two Geolocations?

I'm build an app for an Android smartphone with Phonegape and jQuery mobile.

I want to build an app which uses an arrow which points to a given geolocation, so the user knows in which direction he/she has to go to reach that point.
So I need a function or formula which determines an angle (preferably in degrees) to the destination geo position. Does anyone know how I can do this?

like image 380
Siggy Petersen Avatar asked Sep 14 '25 17:09

Siggy Petersen


1 Answers

What you're looking for is called an azimuth, that is the angle between a given object and the north.

To find that angle you use the formula: a = arctan(|(y2-y1)/(x2-x1)|) * 180/pi Where point A is (y2,x2) and point B is (y1,x1).

As to how you do it in code, I have no idea. I don't work with those platforms. Anyone has any input on this?

like image 110
Michael Avatar answered Sep 16 '25 06:09

Michael