Sign in to follow this  
briantsim

Degrees Question?

Recommended Posts

I like to use a little song:

~\. The dot product of the two position vectors is equal to the cosine of the angle between them ~\.

Sing it to the tune of "Do your ears hang low?"

Share this post


Link to post
Share on other sites
The second verse goes something like

~\. Consequently the angle is the arc cosine of the dot product of the two position vectors ~\.

Finally, the refrain is:

~\. Divide by pi and multiply by one hundred and eighty for degrees ~\.

Share this post


Link to post
Share on other sites
Bravo! Encore!

And an alternative method:

atan( (y2 - y1) / (x2 - x1) )

since tangent is the opposite over adjacent, you take the arc tangent of the opposite over adjacent to get the angle.

Though you have to check whether or not x2 - x1 is equal to zero before doing the division. Some languages (like C++) supply an "atan2" function which make this simpler:

atan2( y2 - y1, x2 - x1 )

No need to check for dividing by zero. It basically takes two parameters, the opposite and the adjacent side's lengths.

Share this post


Link to post
Share on other sites
Those two methods compute different things. Of course, the OP didn't specify which of the two he wanted, so it's not like one of them is correct and one is incorrect. Because he said "positions", he probably meant to get the atan answer. Anyway, two positions don't determine an angle, so the question needs to be posed better.

The acos version measures the angle (x1,y1)-(0,0)-(x2,y2), without sign. The atan version measures the angle (x1+1,y1)-(x1,y1)-(x2,y2), with sign.

Also, in the acos version, you need to divide the dot product by the sizes of the two vectors.

Share this post


Link to post
Share on other sites
Drilian and PfhorSlayer i think you 're talking about normalized vectors. For vectors of arbitary length, like position vectors, take the dot product of the two vectors, then divide the dot product by both the lengths of the two vectors, and then you have the cosine of the angle between the vectors.

Share this post


Link to post
Share on other sites
Quote:
Original post by D_Tr
Drilian and PfhorSlayer i think you 're talking about normalized vectors. For vectors of arbitary length, like position vectors, take the dot product of the two vectors, then divide the dot product by both the lengths of the two vectors, and then you have the cosine of the angle between the vectors.


Multiplication is commutative in real algebra.

Share this post


Link to post
Share on other sites
@taby:

Sorry mate i didn't understand your comment. All i wanted to say is that the dot product of 2 vectors is not just the cosine of the angle between them, but it is the cosine multiplied by their lenghts, namely multplied by |v1|*|v2|. I don't think i murdered commutativeness of multiplication anywhere in my post :P. This is what alvaro is also saying in his last comment too.

Share this post


Link to post
Share on other sites

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

Sign in to follow this