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

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


  • 4
  • 3
  • 2
1 Solution
the angle is arcos((v1.v2)/(|v1||v2|))
verintsupportAuthor Commented:
Thank you

Now how do you get v1.v2 and |v1||v2| with simple math.
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.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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.
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
Ignore my answer, it is very wrong.
Degrees of long and lat are not the same size at (-95, 34).
You may read here about vectors if you needed further knowledge.
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
verintsupportAuthor Commented:

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


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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now