Advertisement

loss of accuracy

Started by December 31, 2001 06:53 AM
3 comments, last by dadio 23 years, 1 month ago
I''m using a camera class that calculates the new matrix for every frame and loads it. Since I use small floats... I feel like I''m loosing my accuracy. The matrix seem to distort as the game goes, and the movement isn''t accurate . Does anyone have an idea on this? thx
Use double precision floating numbers. The PC FPU uses them from default, so using single precision floats will slow down a bit the program and will give you loss of precision. The advantage of using floats instead of doubles is the memory space you are saving.
Advertisement
Excuse me, but it is nonsense to recommend using doubles in that case.

If your matrix is drifting away, then there is obviously a big mathematical problem in your code. Doubles would just hide the problem for a certain time, but the drifting also occurs and you will notice it after a longer period.

You should make sure, that you *never* use previous frame matrices to evaluate the current one. Drifting is preprogrammed, if you do that. You can renormalize your matrix every frame, but that''s not a good solution. The only right way to do it, is to reevaluate the current frame matrix at each and every frame. From camera angles, quaternions, or whatever other representation you have. Then you upload this fresh matrix to your 3D card at every frame.

Floats are totally sufficient for 3d graphics. Physical or accurate mathematical simulation is the only domain, where is see to need to use doubles. Floats are faster (at least on x86), are used by most (if not all) OpenGL implementations internally, and use less space.

quote:

The PC FPU uses them from default, so using single precision floats will slow down a bit the program and will give you loss of precision.



This is wrong. They are used by default, but they are slower. Switching the FPU to 32bit mode (floats), will tradeoff speed for accuracy: floats are faster, but less accurate. Although accuracy is enough for 3D graphics, as said above.
- AH
You can renormalize the matrix every 10 seconds or so.
How do u re-normalize a matrix?

This topic is closed to new replies.

Advertisement