Dot product problem ...please help
angle=acos(dot(normalizedvectorA,normalizedvectorB))
here, angle holds 0 to pi
if i want to rotate from normalizedvectorA to normalizedvectorB, i have to rotate angle amount. but in what direction? left or right? angle is always positive.
please help.
nb. Anyone can give me a qarternion to eulerangle routine
thanx in advance.
Woops!!!
Topu Reza
Hasinur Rahman Rezawww.trimatrik.com
The direction of the vector resulting from the cross product of the two vectors will give you a clue. If they are offset in one direction, the vector will point up. The other way, it points down. For 3-element vectors, anyway.
Does a cross product on two-element vectors result in a scalar number? I can't remember. I haven't dealt with 2D issues in a while!
Edited by - Waverider on March 5, 2002 2:48:30 PM
Does a cross product on two-element vectors result in a scalar number? I can't remember. I haven't dealt with 2D issues in a while!
Edited by - Waverider on March 5, 2002 2:48:30 PM
It's not what you're taught, it's what you learn.
Waverider is correct. If you want to rotate normalizedvectorA into normalizedvectorB, you have to look at their cross product.
Here's more info. The vector to rotate about IS the normalized cross product of A cross B. Rotate A about the axis given by A cross B by the angle calculated using acos(A dot B). If A and B are both in the xy plane, then the axis of rotation will have only a Z component, and that component will be positive or negative depending on the cross product.
The key here is that the first vector in the cross product equation must be the vector that you want to rotate. If you wanted B to rotate into A, you'd rotate by the same angle, but about the axis given by B cross A instead of A cross B. Make sense?
I'm going to ramble on for a while here. Read if you feel like it. You might learn something obscure in the process!
Please note that the cross product of two vectors only exists as a 3D vector. Even though the original 2 vectors might be in 2D (x,y), the cross product pokes out of the xy plane into the z direction, making the space represented by the 3 vectors a fully 3D space.
Cross product is always a vector in whatever subspace your original vectors are in. And it is always perpendicular to the input vectors that determine the cross product. To make things more confusing, the cross product in an N-dimensional space is defined in terms of (N-1) vectors. So, weirdly, the cross product in 2D space (N = 2) only requires one vector input (N-1 = 1). It is valid in 2D to say "the cross product of vector A is....vector B". While in 3D (N = 3), you need (N-1) = 2 vectors: "the cross product of vector A and vector B is....vector C". Does this make sense? So in 2D, if you have some vector A, the cross product is just one of the two vectors perpendicular to A. In computer graphics, it is certainly most common to deal with 3D cross products, even if the geometry is really in 2D.
That may be very very confusing, but it is theoretically the way things are by the traditional definition of cross product.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Edited by - grhodes_at_work on March 5, 2002 3:58:08 PM
Here's more info. The vector to rotate about IS the normalized cross product of A cross B. Rotate A about the axis given by A cross B by the angle calculated using acos(A dot B). If A and B are both in the xy plane, then the axis of rotation will have only a Z component, and that component will be positive or negative depending on the cross product.
The key here is that the first vector in the cross product equation must be the vector that you want to rotate. If you wanted B to rotate into A, you'd rotate by the same angle, but about the axis given by B cross A instead of A cross B. Make sense?
I'm going to ramble on for a while here. Read if you feel like it. You might learn something obscure in the process!
Please note that the cross product of two vectors only exists as a 3D vector. Even though the original 2 vectors might be in 2D (x,y), the cross product pokes out of the xy plane into the z direction, making the space represented by the 3 vectors a fully 3D space.
Cross product is always a vector in whatever subspace your original vectors are in. And it is always perpendicular to the input vectors that determine the cross product. To make things more confusing, the cross product in an N-dimensional space is defined in terms of (N-1) vectors. So, weirdly, the cross product in 2D space (N = 2) only requires one vector input (N-1 = 1). It is valid in 2D to say "the cross product of vector A is....vector B". While in 3D (N = 3), you need (N-1) = 2 vectors: "the cross product of vector A and vector B is....vector C". Does this make sense? So in 2D, if you have some vector A, the cross product is just one of the two vectors perpendicular to A. In computer graphics, it is certainly most common to deal with 3D cross products, even if the geometry is really in 2D.
That may be very very confusing, but it is theoretically the way things are by the traditional definition of cross product.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Edited by - grhodes_at_work on March 5, 2002 3:58:08 PM
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement