Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate the angle between three points based on Latitude/Longitude

Below is the map that captures from Google Map. I want to calculate the angle ABC. I have the coordinate (Latitude/Longitude) of three points.

Is there any approach to resolve my problem?

Thanks

enter image description here

like image 390
Thinh Phan Avatar asked Oct 19 '25 08:10

Thinh Phan


2 Answers

You can find the heading between any two points using the google.maps.geometry.spherical.computeHeading method of the Google Maps Javascript API v3:

computeHeading(from:LatLng, to:LatLng) | number | Returns the heading from one LatLng to another LatLng. Headings are expressed in degrees clockwise from North within the range [-180,180).

The angle between the two will be the difference between the 2 headings.

Example using computeHeading in this answer

like image 153
geocodezip Avatar answered Oct 22 '25 04:10

geocodezip


You can approximate the angle using the law of cosines. I say approximate because the curvature of the Earth is going to have some non-zero effect on the calculation.

In your example it should suffice to calculate the distances between the points and then perform the appropriate manipulations on the law of cosines. Refer to the second formula in the applications of the law of cosines wiki article and the corresponding picture.

like image 37
JSchlather Avatar answered Oct 22 '25 04:10

JSchlather



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!