• Status: Solved
• Priority: Medium
• Security: Public
• Views: 981

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

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

thanks

Richard
0
verintsupport
• 4
• 3
• 2
1 Solution

Commented:
the angle is arcos((v1.v2)/(|v1||v2|))
0

Author Commented:
Thank you

Now how do you get v1.v2 and |v1||v2| with simple math.
0

Commented:
And
A.B = Ax * Bx + Ay * By
You have the lat and long of the points so you can calculate Ax, Ay, Bx, By by subtracting the lats and longs of the corresponding points (assume A and B are v1 and v2).
So you have the way to calculate v1.v2

You have the magnitudes of v1 and v2 which are 0.218 km and 1.062 km
So by multiplying them you have |v1||v2|
And that's all you need.
0

Commented:
a     -95.770712     34.934324
b     -95.768356     34.933977
c     -95.774587     34.925908

Subtract the b coordinates to redefine the origin:

a'      -0.002356      0.000347     171.62 deg      use atan2(long, lat) to find the heading
b'       0.000000      0.000000
c'      -0.006231     -0.008069     232.32 deg

60.71 deg      the difference between the headings.

All this is a planar approximation to a sphere,
which should be okay considering the small distances involved.
0

Commented:
The lag and long values are in degrees I suppose, so you have to convert them in km.
The difference between lats of the two points for A is (-95.77071229704562  -  (-95.76835645203101))
The diff between longs of the two points for A is (34.9343240443434 - 34.9339768366878)
If these two values are named x and y, you can calculate the hypotenuse as sqrt(x*x+y*y)
Let's name this value z
Let X is the corresponding value for x in km
So you have X/x = 0.218/z
you already know x and y, thus you find the X
0

Commented:
Ignore my answer, it is very wrong.
Degrees of long and lat are not the same size at (-95, 34).
0

Commented:
http://www.euclideanspace.com/maths/algebra/vectors/index.htm
0

Commented:
At the equator, degrees of long and lat are the same size:   ~70 miles/deg
As you move north or south, deg lat stay the same, but deg long shrink by cos(lat)

So it is not correct to treat the long and lat coordinates as distances.

a    -95.770712    34.934324
b    -95.768356    34.933977
c    -95.774587    34.925908

a'    -0.002356     0.000347
b'     0.000000     0.000000
c'    -0.006231    -0.008069

Correcting for the latitude:

a"    -0.001932     0.000347        169.82 deg
b"     0.000000     0.000000
c"    -0.005109    -0.008069        237.66 deg
--------------------------------------------------------
67.84 deg
0

Author Commented:
d-glitch,

please view question http://www.experts-exchange.com/Miscellaneous/Math_Science/Q_21835596.html for you.

Thanks

Richard
0
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.