Floating Point Limitations?

Started by
3 comments, last by Void 24 years, 1 month ago
If floating points have not accurately represented in the PC (the IEEE standard), how should libraries using floating points be written? Say, u normalize a vector, there is some small errors. You do many calculations on it. Won''t the error accumlate to a point that the vector will no longer will normalized => therefore causing the maths to fail?
Advertisement
Yes, you will start to pick up some inaccuracies as you go along. One way to prevent this (when performing 3d rotations, for example) is to keep an original copy of the matrices and perform your calculations from there each time. For example, if you are doing some sort of 3d rotations, don''t keep multiplying in the new rotations. Instead, keep track of how much you need to rotate the object and then compute those from the original matrix.

I hope that makes sense. I guess what I''m saying is this: you are going to have some slight inaccuracy every frame, but since you are using the original ''precise'' coordinates as the base for your calculations each frame, it won''t be noticeable.

I don''t know if that will help you out in the general case, but I hope you can use that info for something.
Thanks for the reply..

but nope, I cannot have a copy original value used.

Say I''m calculating the dot product of two vectors, the returned value MUST be between -1 and 1.

However after some time ( I use it few thousands times per second) , the value could be out of 1 and -1.
This would kill acos and result in a infinity value.

Unless I would have to clamp the values down but I noticed many sample libraries do not do that. If I have to clamp down everything function, then it is hell going to be slow. (cause I''m dealing with quaternnios, and unit quaternions calculations should return a unit quaternion, which is not the case with the error accumulation)

..
You must renormalize your quaternions after rotation. You can perhaps skip it a few frames, but every once in a while it must be done.

You can never get completely away from the accuracy problem of floats (double have higher precision but the problems reside).

For the dotproblem and acos problem, you must clamp the value. Because even directly after a normalization your vector will not be exactly of length one.

I see..thanks..

All those quaternion libraries I''m looking at DO not clamp or renormalize.

This topic is closed to new replies.

Advertisement