• Advertisement
Sign in to follow this  

Angle about...

This topic is 4901 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can someone tell me how to compute the angle between two 3D vectors, v1 and v2 where the angle is taken to be counterclockwise about v3 (v3 is assumed to be perpendicular to v1 and v2). Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Dot product obviously doesn't work since it is commutative (for vectors with real entries), so clockwise/anticlockwise information is lost.

You need to do a cross product for that,

aXb = |a||b|sin(theta) _n_

where _n_ is the vector perpendicular to a and b (can't remember if its left or right handed though). You should be able to solve the above equation for theta pretty easily.

Share this post


Link to post
Share on other sites
I am confused by this formula...

aXb = |a||b|sin(theta) _n_

First, I thought you could not divide a vector by another vector. And if you can, do you divide one vector's x by the other's x, and so on?

Second, if "a cross product b" (aXb) gives you a perpendicular vector and you are dividing by another perpendiculalar vector _n_, won't the formula just be...

sin(theta) = 1 / (|a||b|)

Share this post


Link to post
Share on other sites
Divide aXb by |a||b|, call this vector r (say).

r = sin(theta) _n_

_n_ is the axis you want to rotate around (normalised) - that's an INPUT to this equation.
Solve for any of the coordinates of the resultant vector to get the answer.

Share this post


Link to post
Share on other sites
I am still confused by this...

Solve for any of the coordinates of the resultant vector to get the answer.

How can you do...

sin(theta) = someVector / _n_;

Share this post


Link to post
Share on other sites
angle between A and B, looking from C:

vec3 cross=CrossProduct(A,B);//cross is perpendicular to A and B
double dot=DotProduct(A,B);
double angle=atan2(length(cross),dot);
if(DotProduct(cross,C)<0) angle=-angle;

note that
1: angle is in radians
2: it may have opposite sign to what you want(depends to hand of system). You may need to change "<" to ">"

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement