Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

paulcoz

Rotation about world, instead of object axes?

This topic is 5419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a 3x3 rotation matrix that represents an object''s orientation. I''ve applied several rotations to the object that compound so that rotation always occurs around the object''s rotated x, y, and z axes, not the original world x, y, and z axes. However, as an additional feature I want to be able to rotate objects around the world axes as well. That''s where the problem begins because I can''t stop the objects rotating around the new rotated axes. I thought it would make sense to reverse the matrix order so that instead of applying a yaw rotation matrix: [cos a, 0, -sin a] [0, 1, 0] [sin a, 0, cos a] to the object''s existing matrix, I would reverse the order to that the orientation became a fresh rotation around the world axes, with the existing matrix applied afterwards, however it still won''t work. I WAS really pleased with this compounding rotation effect, because I used to suffer from gimbal lock, but now I need to be able to rotate both ways and I can''t figure it out. Paulcoz.

Share this post


Link to post
Share on other sites
Advertisement
To rotate around the world z-axis, you need to rotate the vector (0,0,1) by the inverse of your current rotation matrix. This is the world z-axis, so you can just do a standard axis-angle rotation around it. Let me know how it works.


Mike

Edited by - Vetinari on June 24, 2001 1:01:38 AM

Share this post


Link to post
Share on other sites
Vetinari, do you mean this (* asterix for formatting only):

[0,0,1]*X**[1,0,0] x vector
*********[0,1,0] y vector
*********[0,0,1] z vector

It seems that multiplying the 0,0,1 vector by the inverse of the rotation matrix will just give you [0, 0, (z vector z value) ]

What do you do with the resulting vector once you have it? How do you apply this to the existing rotation matrix?

Regards,
Paulcoz.

Edited by - paulcoz on June 24, 2001 2:11:04 AM

Share this post


Link to post
Share on other sites
Ok, here''s the steps, let me know which ones you don''t understand.

1) Invert your current rotation matrix.

2) Apply that to whatever world axis you want to rotate around.

3) Rotate around the resulting vector.


Mike

Share this post


Link to post
Share on other sites
I haven't used an axis-angle representation before, that's why I'm having trouble - it looks like your method comes up with a single vector to rotate around, whereas I'm used to applying a whole matrix when I do local rotations.

The step I don't understand is No. 3. Can you explain how to do the same thing using a UVN vector system? (eg. 3 unit vectors)

Thanks,
Paulcoz.

Edited by - paulcoz on June 24, 2001 9:55:24 PM

Share this post


Link to post
Share on other sites
I''m not that familular with the UVN system. Isn''t it just three vectors (view directon, up direction and right direction) that form a matrix?

To rotate around an arbitray vector, you should multiply your 3x3 rotation matrix (the one you mention in your first sentence of your first post) by the axis-angle matrix. The axis-angle matrix is a bit complex to type here, but it is described in detail on this site in Diana Gruber''s article "Do we Really Need Quaternions?".

It is located here:
http://www.gamedev.net/reference/programming/features/whyquats/

The matrix you want is the second matrix on the first page, matrix ''R''; if you are using a 3x3 matrix, you only need the top left 3x3 matrix of the 4x4 matrix she provides.

So why did you give up on quaternions? They are much easier for this kind of thing.


Mike

Share this post


Link to post
Share on other sites
how about when your problim accurs carnt you faid out your "pre" matrix,like you would a object on a motion path

Share this post


Link to post
Share on other sites
Vetinari,

Now that I've seen your description I think you need to do the following when using the UVN vector system:

(1) Calculate an inverse matrix for the current 3x3.
(2) Calculate a matrix for rotation around the world axis you want.
(3) Multiply these in 1 then 2 order.
(4) Multiply this new matrix by the original 3x3 again.
(5) The matrix calculated in step 4 is the one you apply to your current 3x3 to get the new rotated position.

You rotate your current matrix back to its identity position (perfectly aligned with world axes), perform the new rotation, then apply your starting orientation again to get the final position, I THINK...

I could use your axis-angle matrix in step 2, but I don't have a problem creating rotation matrices for the world axes - it's applying this rotation to my existing matrix that confused me & I think I've found the answer now.

I'll test it out, and let you know how I go (I may need to cry like a baby for help if this doesn't work).

Paulcoz.

Edited by - paulcoz on June 25, 2001 4:05:38 AM

Share this post


Link to post
Share on other sites
For any 3x3 orthonormal matrix, you don''t really need to calculate it''s inverse. Just transpose it, and that will do.
(Consider mathematical proof of this statement your home assignment

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!