Archived

This topic is now archived and is closed to further replies.

Plasmite

correcting matrices

Recommended Posts

This is a very theoretical question (theoretical for me, I''m not this far in programming yet), but I believe this will be a problem for me some day. I have a matrice for an object. When I rotate object a little bit, I multiply the matrice with other matrice. After doing lots of little rotations, I would assume, my matrice gets somehow incorrect or twisted, so that vertexes in the object would not only get rotated but also shifted in some random directions. Is there a way to somehow correct the matrice? I now I could have three angles for each axis, and then create the matrice again and again everytime I draw the object. But I don''t want this kind of rotating here.

Share this post


Link to post
Share on other sites
your problem are rounding errors and after a while your matrix falls apart. its not orthonormal anymore so youd have to make sure every vector is unit length and rebuild part of it to get all vectors orthogonal to each other. thats about 2 sqrts and 2 cross products every now and then.

Share this post


Link to post
Share on other sites
Precision errors are the cause for drifting coordinates.
You should bite the bullet and reconstruct a fresh matrix every frame.
Try quaternion rotations or geometric algebra, they solve much of the problems associated with rotation.

Share this post


Link to post
Share on other sites
2 sqrts and 2 cross products every now and then. This sounds like there is a way to correct the matrice, but oooo... In a bit more detail?

What does orthogonal mean? (I would probably now this, but I''m not good with english and I don''t have dictionary here.)

I have no idea what I should actually do with the matrice, if I found out that a vector of unit length turned out to be, say, 0.98 long after rotation.

Share this post


Link to post
Share on other sites
if you find that then you just normalize it by dividing every coordinate through its length. orthonormal means that all vectors are orthogonal (90°) to each other and unit length.

what you would do is pick two of the vectors, take the crossproduct, normalize one of the old and the new vector and take the crossproduct of those.
basically you just pick one to stay the same and recalculate the two others.

if youre using directx you already have matrix classes that take care of all that. for opengl i tend to abuse it to do the math for me, but reading back data from the card is slow, so its nothing you should do too often.

Share this post


Link to post
Share on other sites