Jump to content
  • Advertisement
Sign in to follow this  
therealremi

how to rotate vertices in local coordinate system?

This topic is 4233 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 these: - vertices in world coordinates - matrix R containing rotation - matrix L specifying local coordinate system Simply multiplying a vertex by R gives me transformation in world space. Instead I would like to have the vertices rotate around object's local axes. Is there any way to "bake" the information about local coordinate system into R? If you feel like answering my post please bear in mind that I'm a poor mathematician.

Share this post


Link to post
Share on other sites
Advertisement
You would need to apply the rotation before moving your points into world space. If you want to rotate your base objects(in local space) then you need your points to be in local space when you apply the rotation. In other words do R*L to get from local space to world space with the new roations instead of L*R. Assuming that L represents the previous transformation from local to world space.

Share this post


Link to post
Share on other sites
Actually the situation is probably more complicated cause what I try to do is to deform mesh vertices wtih a "bone" (which is just a transformation matrix).
So L is the matrix specifying local coordinate system for a bone.
Now I compute R = R*L, and then transform mesh vertices (which use world coordinates) with R but I get some ugly distortion.

Share this post


Link to post
Share on other sites
The order depends on whether you're using row-vectors or column-vectors. For column-vectors, the order should be L*R*x if the point starts out in local space, and x*R*L for row-vectors.

If the point is already in world-space, then you need to transform it into local-space, perform the rotation, and then transform it back into world-space. This is because rotations are always done around the origin. Thus the transformation order would either be L*R*L-1*x or x*L-1*R*L. You can take advantage of the special inversion formula for homogeneous transformation matrices:

Share this post


Link to post
Share on other sites
After some further investigation I have one more question.
Is it possible to store a rotation in some local coordinate space in a quaternion?
If I reconstruct a rotation matrix from such quaternion, will it contain the rotation around local axes or world axes?

Share this post


Link to post
Share on other sites
A rotation is just a rotation and you can store it in a matrix or a quaternion. When you apply it determines what space the rotation is applied in. If you need it to be applied in a space that your points aren't currently in you'll have to move them back into that space and apply the rotation and then transform them back out of that space like Zipster suggested.

Quote:

Is there any way to "bake" the information about local coordinate system into R?

You could possibly put the transformation into and out of local space into the "rotation" matrix, but since objects have different local spaces you would have to do it seperately for each object. Something like R=L*R*L^-1 or R=L^-1*R*L depending on what type of vectors you're using.

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!