Sign in to follow this  
Weng

How to change a rotation matrix from its existing rotation to another?

Recommended Posts

Weng    122
I would like to change a game object's rotation matrix to match the rotation of another game object. Currently, I am able to retrieve the rotation matrices of the 2 game objects. How should I change the rotation matrix of an object to enable it to have the same orientation as the other game object? The rotation changes will be along the x or z axis and the rotation matrix is a 3x3 matrix.

Share this post


Link to post
Share on other sites
Weng    122
Yes I used this but what if the rotation effect needs to be gradual?

i.e. A camera view gradually rotating from 1 view to another view.

Share this post


Link to post
Share on other sites
haegarr    7372
By interpolation using a weight that increases from 0 to 1 in the time you want to go from orientation A to orientation B.

That said, generally interpolating rotation matrices can be done but isn't a straight forward job. This is usually the time where quaternions should be uncased from the programmer's toolbox. So convert both orientation matrices to quaternions, interpolate the quaternions, convert the time current quaternion back into a matrix, and use that. (Just a tip: Don't try to understand quaternions as something other than a mathematical way of describing rotations.) EDIT: Yep, Hodgman already said it, and he's right :) /EDIT

However, if your rotations are really restricted to 1 common axis at a time (cited from the OP: "will be along the x or z axis") then you can also use the dot-product to get the needed rotation angle. Then interpolate the angle as mentioned above, and use a usual rotation matrix for the given axis and angle to compute the time current rotation matrix. (Not even axis/angle rotation conversion would be needed.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this