How can i calculate the angle between 2 vectors lat long?

x: lat, long
a: -95.77071229704562,34.9343240443434
b: -95.76835645203101,34.9339768366878
c: -95.774587384548,34.9259077248493

vector A is ba
vector B is bc

I have the distance in km of both vectors

A 0.218 km
B 1.062 km


Who is Participating?
You use the dot product of the two vectors, this gives the cosine of the angle between them by projecting the first vector onto the second:
A(dot)B = mod(A) x mod(B) x cos(angle)

A = ax+by = (a, b)
B = mx+ny = (m, n)
And so:
A(dot)B = am + bn
mod(A) = sqrt(a^2 + b^2)
mod(B) = sqrt(m^2 + n^2)

angle = cos<sup>-1</sup>((am + bn) / (sqrt(a^2 + b^2) * sqrt(m^2 + n^2))

And you can work out your vectors from (restarting the notation usage!):
a: (m, n)
b: (o, p)
c: (q, r)

A = ba = (m - o, n - p)
B = bc = (q - o, r - p)

Sorry for the horrendous notation: its impossible to write vector math on the web!

PS. I'm guessing that this is for some kind of GPS work? In which case, you can't truly approximate lat and long on a 2D plane without enormous errors unless points are _very_ close together. Surface of a sphere is a 1st order approximation, but one that gives errors over larger distances, an ellipsoid is better still.

Just found a reference for the dot products and angles between two vectors which might help clear up any notation problems from above (like the attempted superscript on the cos-1):

Another online tool for computing the angle:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.