Sign in to follow this  
kelaklub

Angle about...

Recommended Posts

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
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

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