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
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)
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.
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.
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; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With