TITLE: How to calculate the angle between two vectors, defined by 3 points on the earth?
QUESTION [0 upvotes]: 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 :)

REPLY [1 votes]: 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.

REPLY [1 votes]: Calculate the $x,y,z$ and $X,Y,Z$ coordinates of the two points. For this you need the formulas for spherical coordinates: $(x,y,z) = (\cos a \cos b, \cos a \sin b, \sin a)$.
Then calculate the scalar product of the two vectors: $p = x X + y Y + z Z$.
Then get the angle as $\arccos(p)$.
Edit: I am sorry, I thought O would be the centre of the earth. With 3 points on the earth, the other answer is correct (project onto the plane that is tangent to earth at point O).
{"set_name": "stack_exchange", "score": 0, "question_id": 562083}