Absolute Axis
by Phillip O'Shea · in Torque Game Engine · 02/20/2008 (12:13 pm) · 3 replies
Howdy,
I've got an object that I want to rotate. At the moment I am doing this:
My problem is that when I change the axis I am rotating it on, it uses the internal axis. For example: I rotate 180 degrees around the x-axis, so that the object's base is now on top. I then rotate it 45 degrees around the y-axis and it has rotated the wrong way.
Is there a method where I can rotate an object around the normal axis and not the object's own? I am thinking that i have to somehow find the object's orientation before I transform it, but how do I do this?
Cheers
I've got an object that I want to rotate. At the moment I am doing this:
MatrixF ourTransform = getTransform(); EulerF reffAxis(rotationAxis * angle); MatrixF reffMat(reffAxis); ourTransform.mul(reffMat); setTransform(ourTransform);
My problem is that when I change the axis I am rotating it on, it uses the internal axis. For example: I rotate 180 degrees around the x-axis, so that the object's base is now on top. I then rotate it 45 degrees around the y-axis and it has rotated the wrong way.
Is there a method where I can rotate an object around the normal axis and not the object's own? I am thinking that i have to somehow find the object's orientation before I transform it, but how do I do this?
Cheers
About the author
Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.
#2
you might need/want to strip any translation out of the matrix tho.
perhaps something like this: (exact syntax probably off)
02/25/2008 (12:13 am)
Maybe tryreffMat.mul(ourTransform); setTransform(reffMat);?
you might need/want to strip any translation out of the matrix tho.
perhaps something like this: (exact syntax probably off)
m1 = getTransform(); p1 = m1.getColumn(3); // translation m1.setColumn(3, Point3F(0, 0, 0)); m2 = worldSpaceRotationMatrix; m2.mul(m1); m2.setColumn(3, p1); setTransform(m2);
#3
In my example, rather than creating a matrix for z-axis rotation using something that looks like:
I need:
02/25/2008 (1:04 am)
Still suffers from the same problem.In my example, rather than creating a matrix for z-axis rotation using something that looks like:
MatrixF reffMat(0.0f, 0.0f, angle);
I need:
MatrixF reffMat(0.0f, angle, 0.0f);
Associate Phillip O'Shea
Violent Tulip
When you rotate an object using matrix multiplication, you always use the object's current rotation as a reference for the next rotation being applied.
When the rotation is (0 0 0) the matrix looks like this:
When you rotate the object around the x-axis by 90 degrees, it should look something like this (I think there is meant to be a negative 1 in there somewhere, but I forget):
If I want to now rotate the object around the world's z axis, then I have to rotate the object using its y-axis. Obviously I can use the transformation matrix to see what the rotation axis *should* be, I just don't know howI should go about doing it.