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

Posted on 2006-05-02
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
    LVL 11

    Expert Comment

    the angle is arcos((v1.v2)/(|v1||v2|))

    Author Comment

    Thank you

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

    Accepted Solution

    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.
    LVL 26

    Expert Comment

    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

    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 26

    Expert Comment

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

    Expert Comment

    You may read here about vectors if you needed further knowledge.
    LVL 26

    Expert Comment

    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


    please view question for you.



    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Baseline sigma 8 22
    Michel Meyer experiments 40 194
    Loan to Value to interest rate relationship formula 1 123
    Probability Distribution 5 29
    How to Win a Jar of Candy Corn: A Scientific Approach! I love mathematics. If you love mathematics also, you may enjoy this tip on how to use math to win your own jar of candy corn and to impress your friends. As I said, I love math, but I gu…
    Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! How to Know You are Making a Difference at EE In August, 2013, one …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now