• Advertisement
Sign in to follow this  

Rotation around two axis

This topic is 3413 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

hi what would the best way to go about rotating an object around two origins, ie rotating in the y-axis around the centre of the object and rotating in the x-axis around one corner of the object, for example. The only way i can see to do it is by Matrix.CreateTranslation(offset1) * CreateRotationY(rotY) * Matrix.CreateTranslation(-offset1) * Matrix.CreateTranslation(offset2) * CreateRotationX(rotX) * Matrix.CreateTranslation(-offset2) which seems awfully clumsy so i was just wondering if there was a more optimized way of doing it that any of you know? the other problem is that say i want to rotate in the y-axis around the center but when i press a certain button i want it to rotate in the same axis but this time around the corner... ive tried by just changing the value of 'offset' when i press the button but the model jumps so the point of rotation is always in the same world space. any ideas on how to prevent this? oh and by the way im using c# and xna but the question is quite general so just some pseudo-code in any language would be much appreciated. thanks.

Share this post


Link to post
Share on other sites
Advertisement
In principal, that is exactly the way to go. It isn't clumsy but a normal composition of transformation matrices.

For the general case there is only a small optimization possible:
Matrix.CreateTranslation(-offset1) * Matrix.CreateTranslation(offset2) == Matrix.CreateTranslation(offset2-offset1)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement