#### Archived

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

# Matrix Rotation Centered off of the Origin

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

## Recommended Posts

Hey, I am using 4x4 matrices to do my rotations and I was wondering if there was some way to rotate around a point OTHER than 0, 0, 0. It is for skeletal animation. As most of the bones are not located exactly at 0, 0, 0, and I do not want to move all of the parts of the model to 0, 0, 0 to compensate, I need to know if this is possible or not and if so how I can do it. Thanks in advance. Walt

##### Share on other sites
Yes it is possible. If your center of rotation is P, then first you translate by -P, then perform your rotations, and then translate by P. (not sure about the order of matrix multiplications require, but should be able to guess it in two tries)

##### Share on other sites
Hey...
Uhhh I tried this... (with P as position, total rot as previous bones'' sum rotation, rot as this bones new rotation)

NewRot = Matrix(-P) * TotalRot * rot * Matrix(P);

And the rotation screws up the final translation... how can i fix this? I tried moving the multiplies around but it didn''t work

Walt

##### Share on other sites
Update:

I''ve found that it works *better* to do this:

NewRot = TotalRot * (Matrix(-Loc) * Rot * Matrix(Loc * Rot.GetTranspose33()))

But it still doesn''t work... Rot is the rotation of the current bone and TotalRot is the NewRot of the previous bone (thus forming a chain of rotations and translations which should work....)

##### Share on other sites
w00t! anyway, i fixed it, you have to do this (in case anyone''s interested, which, if you are, post a message so i''ll know this wasn''t in vain) :

NewRot = TotalRot * (Matrix(Loc) * Rot * Matrix(-Loc));

where, once again, the totalrot is the NewRot of the parent bones for this bone. The Loc''s are the locations BEFORE any transformation also.

Walt

1. 1
2. 2
Rutin
22
3. 3
4. 4
JoeJ
17
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002297
×