Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 25 October 2004 - 01:04 AM
Posted 25 October 2004 - 01:13 AM
Posted 25 October 2004 - 04:20 AM
Posted 25 October 2004 - 04:29 AM
Quote:
Original post by gaimplay
I'm trying to figure out how to orthonormalize a rotation matrix so that the basis vectors would be unit length and perpendicular. This is to combat floating point precision errors that accumulate in the matrix.
The way I figured it, all you need to do is take a unit vector, transform it by your current rotation matrix, then inspect the resulting vector and build a some kind of a scaling matrix that makes the resulting vector unit length, then concatenate this matrix with your current one to fix it.
If I'm way off course, it would be great if someone could post some pseudo code or actual code to demonstate the correct algorithm.
I'm currently using DX9 but can't find a built-in function to do this kind of thing.
Any help appreciated.
Posted 25 October 2004 - 04:41 AM
Quote:
Original post by Charles B
Consider storing dynamic referentials (where you accumulate transfos) as Quaternions, AxisAngle or EulerAngles if possible. Renormalizing matrices will necessarilly be more unstable. Then use conversions when required to pass something to DX9 for instance.
Posted 25 October 2004 - 06:31 AM
Posted 25 October 2004 - 06:56 AM
Quote:
Original post by Anonymous Poster
Gramm-Schmidt Orthogonalization Too complicated, the two cross product much faster and practical
Column1=Normalized(CrossProduct(Column2,Column3));
Column2=Normalized(CrossProduct(Column3,Column1));
Not need to renormalize Column3 as it is already part of the matrix.
Elco quote:
"quaternions are a much better way to store orientations than matrices. the only thing matrices are best for is transforming coordinates actually, so they should only be generated just before transforming your stuff ideally."
You should disclaim this by saying is you opnion not a fact.
Quatenions are good for key frame interpolation and physics but they are in fact a terrible way to store transformation matrices. Just think of a scene graph with tenth of children in which the application have to transform and rotate vectors several time. Rotation of a vector by a quaternion while it is possible it is about 8 time more expensive than rotation by the matrix equivalent. If you do not belief me then you look and two mayor graphics apis OpneGL and direct3d they use matrices to form matrix stack, not quaternion.
Posted 25 October 2004 - 07:31 AM
Quote:
Original post by Anonymous Poster
Gramm-Schmidt Orthogonalization Too complicated, the two cross product much faster and practical
Column1=Normalized(CrossProduct(Column2,Column3));
Column2=Normalized(CrossProduct(Column3,Column1));
Not need to renormalize Column3 as it is already part of the matrix.
Elco quote:
"quaternions are a much better way to store orientations than matrices. the only thing matrices are best for is transforming coordinates actually, so they should only be generated just before transforming your stuff ideally."
You should disclaim this by saying is you opnion not a fact.
Quatenions are good for key frame interpolation and physics but they are in fact a terrible way to store transformation matrices. Just think of a scene graph with tenth of children in which the application have to transform and rotate vectors several time. Rotation of a vector by a quaternion while it is possible it is about 8 time more expensive than rotation by the matrix equivalent. If you do not belief me then you look and two mayor graphics apis OpneGL and direct3d they use matrices to form matrix stack, not quaternion.
Posted 25 October 2004 - 07:48 AM
Posted 25 October 2004 - 08:42 AM
Quote:
Original post by Anonymous Poster
The same lost of orthogonality that happens to matrices when you multiplying then together also happen to quaternions. You said yourself when you mention “and one normalization it's everything you need”
Posted 25 October 2004 - 09:02 AM
Posted 25 October 2004 - 09:09 AM
Posted 25 October 2004 - 09:19 AM
Posted 25 October 2004 - 09:21 AM
Posted 25 October 2004 - 09:29 AM
Quote:
Original post by Anonymous Poster
“a quat is always ortho, if not unit length.”
Not really, take quaternion a(0.5, 0.5, 0.5, 0.5)
When multiplied repeatedly by another quat say b(cos(a/2), 0, sin(a/2), 0)
Will introduces and error of the same nature than the product of the equivalent matrices, So in both case normalization is required. In the case of quaternion what you get is not longer a quaternion, it is forced to map into a neighbor quaternion by the normalization which nothing than a projection. So quaternions, just like orthonormal matrices, do lose orthogonality as result of round of errors.
Quote:
“and one normalization is quite a lot faster than renomalizing and reothogonizing a matrix.”
True, but you have to take the whole picture. The normalization in faster on a single quaternion, but given that this lost of orthogonality can only happens as the result of a multiplication by anther quaternion. When you need to get the product of two matrices from two quaternions the operation is up to 5 to 6 time slower
Quote:
My point is: quaternions are good for storing rotations and to encode animations, but there are not practical as build block for a graphic engine.
I am not saying quaternions cannot be used to represent rotations, but if you are going to recomend that option you need to explain everything not just a bias opinion.
Posted 25 October 2004 - 09:48 AM
Posted 25 October 2004 - 10:41 AM
Quote:
Original post by Anonymous Poster
Try to get a matrix from this quat q(0.3, 0.5, 0.5, 0.5) and tell me what you get.
Quote:
Try to get the aiming vector from a bone way down a skeleton with all transformations are encoded as quaternion, and do the same with matrices.
Quote:
“i still think its more elegant to keep these things seperated in quats for rotation, and vectors for shearing, translation and scaling, but i admit that might just be a personal thing due to my hang for elegance, and not really be more efficient.”
I already proved quaternion are by no mean faster for transformation manipulation and elegance is in the eye of the beholder, I personally think and a quaternion and a position is less elegant and less efficient, than a single transformation matrix. (one operation, one member representaion for a matrix)
Apparently all video card manufactures, Microsoft directx, Opengl, not to mention all graphic packages like Max, soft image, Maya, Softimage XSI ect. Agree with me.
Posted 25 October 2004 - 10:58 AM
Posted 25 October 2004 - 11:18 AM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.