Skip to main content
gamedev.net
🔒 Locked

Basic dot product question

Started by Crazy Chicken Jan 14, 2005 at 8:05 AM 2 replies 1.1k views
Original Post
Crazy Chicken
Crazy Chicken
I have a basic question about the dot product. If I want to compute the angle between two vectors I know that I need to take the inverse cosine of the dot product between the two vectors in question. My questions is: If I wanted to rotate one vector so that it faces in the direction of the other how do I find out whether to rotate clockwise or anticlockwise? Thx [Edited by - Crazy Chicken on January 14, 2005 8:26:05 AM]
TheFatGecko
TheFatGecko
1) Yes, the dot product gives you the smallest angle between two vectors, which is a value between 0 and 180. But it doesn't tell whether it's a positive angle or a negative angle, you have to figure that out with extra information.

2) (but) you can use the cross product A x B to give a vector C. Now a postive rotation about C through angle theta, will rotate vector A to direction of vector B. Where A.B = cos(theta), and A and B are unit vectors. This also assumes a right-handed coordinate system.



[Edited by - TheFatGecko on January 14, 2005 8:24:19 AM]
____________The problem with designing something completely foolproof is tounderestimate the ingenuity of a complete fool. - Douglas AdamsEmail: thefatgecko@yahoo.co.ukhttp://www.geocities.com/thefatgecko
blizzard999
blizzard999
u * v = |u| * |v| * cos(angle)

angle = acos(u*v)/(|u||v|)

if u and v are not normalized you have to divide by |u||v|


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.