# Local and world matrix

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

## Recommended Posts

Hi, A transformation problem is driving me crazy. I have a simple hierarchical 3D human-like model, let's just consider the Thigh (parent) and the Calf (Child). I can read the World transformation matrix of both but can only change the local ones (constraint of the system I am using). The following relationship is true: parent.worldTransform * child.localTransform = child.worldTransform I simply want to translate the knee (joint between the parent and the child) of 5 units along the Y axis IN WORLD SPACE. It sounds easy but all I can get so far is a translation along the Y axis in the LOCAL space (therefore my translation "moves" along the knee and got messed up due to its rotation). I tried the following relation: child.localTransformation = parent.worldTransformation.Inverse * (child.worldTransform * translation(0,5,0)); but the translation is still in local space :'( Can anyone see what's wrong and maybe try to find a way to translate that knee in world space. Thanks a lot

##### Share on other sites
In order to perform a world-space translation, the vertex needs to be in world-space first. This seems to be accomplished just fine by child.worldTransform. So all you need to do next is apply the translation: translate(0,5,0) * child.worldTransform.

##### Share on other sites

Hi Zipster,

Thanks for answering. The problem is that I can't write values in the world matrix, I can only change the local one. That's why I am looking for a way to compute exactly what you wrote for the for the local matrix, not the world one.

##### Share on other sites
If I understood the problem corretly:

If Zipster's solution would work in principle, then what you want is expressed as
T * Cw
where T denotes the translation and Cw the world transform of the child. After setting in the computation of child's world matrix, you'll get
T * Pw * Cl
where Pw denotes the parent's world matrix and Cl the child's local matrix.

Pw * ( T' * Cl )
so you're looking for an equality of
T * Pw * Cl == Pw * T' * Cl

This is solved to
T' = Pw-1 * T * Pw
so that T' defines the equivalent transformation in child's local space.

##### Share on other sites

Thanks for the answer. I kinda messed up my code lately, it's not working as well as it used to. I'll try this solution as soon as i get it to work again and keep you updated. Thanks ;)

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633756
• Total Posts
3013707
×