🎉 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!

Is simple matrix decompose normalizing 3x3 part safe?

Started by
6 comments, last by Alundra 4 years, 8 months ago

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!

Advertisement

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

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. 

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.

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.

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.

The paper you mentioned can fail sometimes, you can see here: https://github.com/bulletphysics/bullet3/issues/1667
EDIT: I didn't read until the end, looks like an author answered and it's not the algorithm fault.

This topic is closed to new replies.

Advertisement