Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate angle between two Latitude/Longitude points

Is there a way to calculate angle between two Latitude/Longitude points?

What I am trying to achieve is to know where the user is heading. For example, user is heading North, South,.... South-East, etc.

But I have only two points (Lng/Ltd)

Thx

like image 535
praethorian Avatar asked Oct 14 '10 11:10

praethorian


People also ask

How do you find the angle between two latitude longitude points?

Here is the formula to find the second point, when first point, bearing and distance is known: latitude of second point = la2 = asin(sin la1 * cos Ad + cos la1 * sin Ad * cos θ), and. longitude of second point = lo2 = lo1 + atan2(sin θ * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)

How do you find the angle of latitude?

Using the protractor, measure the smaller angle between the beam and the plumb line. If the sun is directly over the Equator, this is your latitude reading. The angle to measure when using the sun or North Star. Note that the horizon is always 90º to the plumb line.

How do you calculate degrees of longitude?

To measure the longitude you must place the ruler diagonally on the west and east meridians with the ends of the 2 ½ minute ruler touching both meridians. The lines of longitude on your map will be the east and west meridians of your location.


1 Answers

using this referance to calculate Angle:

private double angleFromCoordinate(double lat1, double long1, double lat2,         double long2) {      double dLon = (long2 - long1);      double y = Math.sin(dLon) * Math.cos(lat2);     double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)             * Math.cos(lat2) * Math.cos(dLon);      double brng = Math.atan2(y, x);      brng = Math.toDegrees(brng);     brng = (brng + 360) % 360;     brng = 360 - brng; // count degrees counter-clockwise - remove to make clockwise      return brng; } 
like image 107
Nayanesh Gupte Avatar answered Sep 28 '22 20:09

Nayanesh Gupte