Jump to content
  • Advertisement
Alundra

Is simple matrix decompose normalizing 3x3 part safe?

Recommended Posts

Hi all,
The easy way to decompose an affine transformation matrix is to:

1) Compute the length of the column (or row), that gives the scale on X, Y and Z.
2) Extract the last column (or row) to have the translation on X, Y and Z.
3) Last part is to normalize the 3x3 and create the quaternion from it.

Is it safe in all cases for an affine transformation matrix?
What about shear/skew?
Thanks!

Share this post


Link to post
Share on other sites
Advertisement

What form are you decomposing it into? A scale vector, quaternion for orientation, and a translation vector?

Share this post


Link to post
Share on other sites

I use polar decomposition. It decomposes a 3x3 matrix into a rotational and 'stretch' matrix. This is a good resource on this topic:

https://research.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf

Say you transform a vertex by a hierarchy of rotations and scale. E.g.

v' = R2 * S2 * ( R1 * S1 * v )

v' = R2 * ( R1 * R1^T  )* S2 * ( R1 * S1 * v )

v' = ( R2 * R1 ) * ( R1^T  * S2 * R1 * S1 ) * v

v' = R * S 

R * S is obviously a valid decomposition,  but the scaling factor is not a pure 'stretch' as it still contains rotation. This can lead to interpolation artifacts. If you just want to bake the scaling part into some geometry this will be fine. So what kind of decomposition you choose depends a bit on what you are trying to do. 

Share this post


Link to post
Share on other sites

I only use decomposition for FBX node transform and when you pass a matrix in the transformation class which then decompose to: Position, Rotation and Scale.
There is 3 way I'm aware of to achieve that: Simple decompose like I said, QR decompostion (gram-schmidt or house holder) and polar decomposition.
I first used Polar Decomposition but then switched to QR decomposition since rotation scaling is always identity from FBX.
My concern was to know if the simple decomposition has problem and when.

Share this post


Link to post
Share on other sites
Posted (edited)

The simple decomposition has problems if you use non-uniform scale in non-leaf nodes as this will introduce shear. I think the FBX documentation even states this as a problem. Practically I would not worry about this very much. Personally I use the built-in decomposition of the FBXAMatrix and never had problems.

Edited by Dirk Gregorius

Share this post


Link to post
Share on other sites

For extracting the rotational part of a 3x3 matrix I use a quaternion based decomposition then convert the result back to a matrix:

http://matthias-mueller-fischer.ch/publications/stablePolarDecomp.pdf 

This method solves a couple of simulation problems and it is extremelly easy to implement.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!