Jump to content
  • Advertisement

Archived

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

Void

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

..

Share this post


Link to post
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 this post


Link to post
Share on other sites
I see..thanks..

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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!