Angle about...
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.
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.
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.
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|)
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|)
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.
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.
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_;
Solve for any of the coordinates of the resultant vector to get the answer.
How can you do...
sin(theta) = someVector / _n_;
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 ">"
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 ">"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement