I have a reference model, (for example a triangle), with its ‘up’ vector definied as <0 1 0> and its ‘over’ vector defined as <1 0 0>.
Now I have another triangle of the same size rotated and positioned arbitrarily in a 3d space. What I want to do is to find out this new triangle’s ‘up’ and ‘over’ vector. I.e. if the triangle is rotated 180 degrees around the X-axis, it’s ‘up’ vector should be <0 -1 0> and its ‘over’ vector should be the same.
How do I find the rotation transformation? If I have this, I can just ‘rotate’ the ‘up’ vector by the inverse to get the new ‘up’ vector and then I’m done.
Any ideas?
Ok everyone. Thanks for the help, but I managed to figure it out.
Here are the steps.
Center both objects at the origin
Rotate one vector onto another, for examble (a0) -> (b0). Now you have to vectors overlapping one another. a0/b0, although points, form vectors from the origin
Find the normals of each of these vectors, this can be done by using an additional point in each coordinate space and finding the cross products. For example:
an = a0 x a1
bn = b0 x b1
Now just rotate an onto bn and you are finished.
The easiest way to do the rotations is to add a ‘rotateTo’ member function that returns a quaternion (Avoids gimbal lock). Then you can multiply the two quaternions together to get the resulting rotation transformation.