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

Posted on 2006-05-02
Medium Priority
Last Modified: 2008-03-10
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


Question by:verintsupport
  • 4
  • 3
  • 2
LVL 11

Expert Comment

ID: 16589592
the angle is arcos((v1.v2)/(|v1||v2|))

Author Comment

ID: 16589612
Thank you

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

Accepted Solution

WelkinMaze earned 2000 total points
ID: 16589690
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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 27

Expert Comment

ID: 16589810
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.
LVL 11

Expert Comment

ID: 16589814
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
LVL 27

Expert Comment

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

Expert Comment

ID: 16589908
You may read here about vectors if you needed further knowledge.
LVL 27

Expert Comment

ID: 16590300
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

Author Comment

ID: 16591346

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



Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Guide to the PMT, FV, IPMT and PPMT Functions In MS Excel we have the PMT, FV, IPMT and PPMT functions, which do a fantastic job for interest rate calculations.  But what if you don't have Excel ? This article is for programmers looking to re…
Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question