#### Archived

This topic is now archived and is closed to further replies.

# Floating Point Limitations?

This topic is 6824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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.

##### Share on other sites

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)

..

##### Share on other sites
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.

##### Share on other sites
I see..thanks..

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

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633289
• Total Posts
3011231
• ### Who's Online (See full list)

There are no registered users currently online

×