🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Inverse Transform Position/Vector

Started by
4 comments, last by _WeirdCat_ 4 years, 4 months ago

Hello

I'm trying to understand linear algebra code i'm reading and i'm stuck visualizing two built in functions for UE4.

  • InverseTransformPositionNoScale(FVector Location)

To give some context:

In the code they get the Root transformation from a animation

InSequence->GetBoneTransform(RootTM, 0, AtTime, false);

Then they get the world transformation of the bone.

GetAnimBoneWorldTM(InSequence, AtTime, BoneIndex, BoneTM);

Near the end of the function they take the root transform and use the inverse functions for the position.

RootTransform.InverseTransformPositionNoScale(BoneTransformLocation);

I looked at how those functions work but I don't get how this helps.

The InverseTransformPositionNoScale function does this:

TranslatedVector = BoneTransformLocation - RootLocation
// ( Rotation.Inverse() * (V-Translation) )
VectorResult = VectorQuaternionInverseRotateVector(Rotation, TranslatedVector);
return VectorResult;

When we subtract the two vectors we will get a resultant vector that would look something B:

Subtracting two vectors by putting their feet together and drawing the result.
Subtraction vector

Now when we translate the vector then rotate it we should get an effect like this?

I want to know if i have the right idea or if im horrible off on all of this.

Thanks!

Advertisement

Well, it is late were I am living and I am quite, so sorry in advance if I misunderstood your question, but to explain this:

ganny said:
TranslatedVector = BoneTransformLocation - RootLocation // ( Rotation.Inverse() * (V-Translation) ) VectorResult = VectorQuaternionInverseRotateVector(Rotation, TranslatedVector); return VectorResult;

A coordinate transformation (without scaling) usually contains 2 steps. First apply a rotation and afterward a translation. So:

W = R * V + T

Now If we have W and want to get the original vector V, we have to undo the translation first.

W - T = R * V

Subsequently, we multiply with the inverse rotation R_i:

R_i * (W - T) = R_i * R * V

R_i * (W - T) = V

The flaw in your picture (side note: it is not really wrong, just not helpful for understanding) is, that your initial object is at the coordinate systems origin. It is more like your rotated object in blue is the starting point of the inverse transformation. You move it back to the origin (if V was located there) and rotate it afterwards.

So forward transformation is (usually) in the order rotation → translation and the inverse transformation is inverse translation → inverse rotation.

Hope that helps.

Greetings

So its moving the object back the vector origin (removing the transform through subtraction) and then un-rotating it by multiplying the current rotation by the inverse.

Then by the end we get the vector that the object started at.

ganny said:

So its moving the object back the vector origin (removing the transform through subtraction) and then un-rotating it by multiplying the current rotation by the inverse.

Then by the end we get the vector that the object started at.

Correct.

Little side note: The inverse of an orthogonal matrix (pure rotations and reflections) is equal to its transposed matrix. So don't bother with complicated formulas to get the inverse rotation matrix. If you are using an engine, it probably does not matter for you. ?

Greetings

Anyway you can get original point with inversion, the only need is that you have to care about rotation translation order (not necessairly)

This topic is closed to new replies.

Advertisement