Sign in to follow this  

What's matrix creep?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I read "Matrix Creep" in <<3D Math for Graphics and Game Development>> but I don't know what it exactly mean. It seems like a sort of "disadvantage" of matrix. I have googled this item but get nothing. Does anybody know what it mean?

Share this post


Link to post
Share on other sites
Just as stated above; floating point drift is a problem in general, but because matrices have a large number of floating point numbers, and therefore a large number of operations for even the basic tasks, the drift tends to be quicker. Couple this with the fact that matrices need to be somewhat more accurate in order to be useful, and suddenly it becomes a moderate concern. It's not a bad idea to normalize rotation matrices, for example, after a while.

Share this post


Link to post
Share on other sites
matrices can have lots of redundant information (compare a four float quaternion and a 9 float rotation matrix). So more can go wrong, and more need to be consistent.

Share this post


Link to post
Share on other sites
I've seen matrix creep happen. Every frame we were converting the vehicles transform to an affine transform and back after physics was done. The scale of the transform would eventually start to creep up in certain axes. I'd go to lunch and come back and the door would look a bit odd. Door joints wouldn't line up.

It was very hard to find. The solution was to not use the extracted scale when converting to affine. So each time we converted back, the proper(initial) scale was preserved. Kind of hacky but it worked.

You should try to only use matrices as a final output for a transformation, and not the actual storage/manipulation.

Share this post


Link to post
Share on other sites
Thank you guys.

So "Matrix Creep" means a sort of "error accumulation". Since there is much more redundant information in matrices, the "error accumulation" could go faster than quaternion or Eular Angle. This phenomenon is called "Matrix Creep".

Am I right?

[Edited by - c43892 on May 29, 2008 9:28:18 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by c43892
...the "error accumulation" could go faster than quaternion or Eular Angle.


Not necessarily. The creep happens any time you convert a value to another range or storage type, and then convert it back and expecting the same result.

float val = 1 / 2.0f;
val *= 2.0f; //val probably isn't going to be 1.0f

The same thing will happen for any storage type (matrix, quaternion, vector). For instance a transform has 3 common properties. Translation, Scaling, and Orientation. Error accumulation in the translation or orientation probably will go unnoticed. If there is physics, the physics will keep these properties in check. However, if no one is keeping the scale in check, it will "creep" or drift away from the expected value.

I'm sure this can happen in many different places. This is the only one I can easily recall.

Share this post


Link to post
Share on other sites
Thank bzroom. It's much more clear.

But I'm still a little confused.
Quote:
Original post by bzroom
Error accumulation in the translation or orientation probably will go unnoticed.

Why? It seems that the three properties: translation, scaling and orientation should have the same problem.

Quote:
Original post by bzroom
The creep happens any time you convert a value to another range or storage type, and then convert it back and expecting the same result.

But it's much more serious in matrices than quaternion or Euler Angle, right?

Share this post


Link to post
Share on other sites
There are four kinds of affine transforms: Rotation, translation, scaling and shear. All of these can be represented by the same matrix, which is where the problem comes from. Euler angles only represent rotations so they although they accumulate error, they never become anything else. Unit quaternions also represent rotations, but as quaternion length starts to drift, they can also scale and shear.
As matrices accumulate error, all of the transformations start to show in the result, even if you only wanted rotation and translation. This can happen simply as a result of multiplying matrices.

[Edited by - SnotBob on May 30, 2008 12:29:31 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by c43892
But it's much more serious in matrices than quaternion or Euler Angle, right?

You normally want your matrix to do rotation and translation. Sometimes (rarely) scaling as well.
Whereas matrix in general could do a lot of things like non-uniform scaling, "shear", etc. Especially so 4D matrices that can do projections as well.
As you multiply matrices in sequence (e.g. when you rotate spaceship with keyboard controls), those transformations accamulate.

The issue with matrix creep is not the inaccuracy in rotation (when you're rotating matrix depending to user input, it doesnt even matter), but matrix becoming non-orthonormal, i.e. doing transforms that you dont want.

To solve the problem, you can re-orthonormalize matrix once in a while, i.e. make 3 base vectors be orthogonal and be unit-length, and for 4x4 matrices, make bottom row (opengl) or right column (DX) be 0,0,0,1 .

With quaternion (for orientation) and vector (for position) (and optionally scalar for scaling, which is handled separately), the only creep of that sort that happens is quaternion length becoming !=1. That scales result by quaternion length^2 . Thats easy to fix, just re-normalize.

Share this post


Link to post
Share on other sites
Thank SnotBob and Dmytry!

Quote:
Original post by SnotBob
There are four kinds of affine transforms: Rotation, translation, scaling and shear. All of these can be represented by the same matrix, which is where the problem comes from.

That's the point!

And Dmytry is an expert! I think it's clear enough now. Thank you guys.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this