# how to rotate vertices in local coordinate system?

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

## 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 on other sites
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 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 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 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 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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
khawk
15
5. 5

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013644
×