# Calculating an angle from vectors

## Recommended Posts

Hi there guys, Sorted Thanks for your help guys. Neil [Edited by - neilski_2003 on April 25, 2006 6:22:36 AM]

#### Share this post

##### Share on other sites
The dot product of two vectors is the cosine of the angle between them times the magnitudes of the vectors. So, if you have two vectors A <x, y> and B <z, w> with an angle T between them, then:

dot(A, B) = cos(T)*mag(A)*mag(B)

so

T = arccos(dot(A,B)/(mag(A)*mag(B))

with
dot(A,B) = x*z + y*w
mag(A) = sqrt(x*x + y*y)
mag(B) = sqrt(z*z + w*w)

#### Share this post

##### Share on other sites
I might not entirely understand what you're asking for. If I don't, then I apologize.

To find the angle between two vectors A and B, use the geometric formula for the dot product:

A dot B = |A| * |B| * cos(alpha)

where alpha is the angle in question. With some manipulations, we have:

cos(alpha) = (A dot B) / (|A| * |B|)
alpha = cos-1((A dot B) / (|A| * |B|))

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

• ### Forum Statistics

• Total Topics
628368
• Total Posts
2982293

• 10
• 9
• 13
• 24
• 11