2D Rotation Floating-point Error
I have a quaternion that converts to a rotation matrix for a 2D(really 3D) quad. For some reason when there is a slight floating-point imprecision in the axis/angle->quaternion->matrix conversion the rotation matrix becomes "invalid" (the quad does not appear to render at all). So if I interpolate the angle across time, the quad rotates fine but flickering, when an element in the matrix is close to 1.0f, but not quite.
For example, the quad doesn't render if its rotation-matrix is
[ +0.00000000, +0.99999994, +0.00000000, +0.00000000,
-0.99999994, +0.00000000, +0.00000000, +0.00000000,
+0.00000000, +0.00000000, +0.99999994, +0.00000000,
+0.00000000, +0.00000000, +0.00000000, +1.00000000 ]
This is at a PI/2 rotation angle, so the matrix should of course be
[ 0, 1, 0, 0
-1, 0, 0, 0
0, 0, 1, 0
0, 0, 0, 1 ]
In fact if I edit these values in the debugger the quad renders fine...
The vertex shader that renders that quad is as straight forward as you can get, (pos * worldviewproj). No inverse trig functions to clamp to or anything.
I understand the imprecision, but why would it affect the visibility of the quad besides a micoscopically different angle than PI/2? From googling this type of thing seems to be a common problem, but how is it resolved and why does it occur?
I will give it a try debugging the shader to see what is actually happening, but I don't know if that will help.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement