Skip to main content
GameDev.net gamedev.net
🔒 Locked

correcting matrices

Started by Plasmite Aug 11, 2003 at 5:23 AM 4 replies 300+ views
Original Post
Plasmite
Plasmite
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.
Trienco
Trienco
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.
f@dzhttp://festini.device-zero.de
Nik02
Nik02
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.
Niko Suni
Plasmite
Plasmite
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.
Trienco
Trienco
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.
f@dzhttp://festini.device-zero.de
JohnBolton
JohnBolton
Look up "Gram-Schmidt orthonormalization".
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.