[Math] How to calculate the angle between two vectors, defined by 3 points on the earth

spherical coordinatesstereographic-projectionstrianglesvectors

I want to develop a formula to calculate the angle between two vectors. The vectors will be OX and OY (from point O to X , and Y), where the points are defined by their latitude and longitude values.

I know that there is a little problem when calculating the angle between 3D vectors, so it could be calculating the angles between OX' and OY' prime, where the points X' and Y' are the projections of X and Y, on the plane that "skews" earth on point O.

Any ideas how to formulize this ?

Thanks in advance 🙂

Best Answer

If you project your vectors onto a plane, you can derive the angle from the dot product. $$a \cdot b = ||a||\,||b|| \cos \theta$$

Or you may want the spherical angle, in which case you will also need the radius of your sphere.