View Full Version : Numerical stability

Thierry Bernier
01-02-2006, 05:06 AM

I have a numerical stability problem.
A small test app draws a textured rectangle of unit length (1.0) . This rectangle is seen from a distance of some units (3.0) and the "camera" is smoothly moved around this point (by steps of 0.001).

It works perfectly well.

But when I translate everything to 1.0e6 units away from 0.0, the movement becomes jitterred.

On my machine (Pentium/Windows, hardwared OpenGL), (1.0e6+1.0e-3)+1.0e-3 perfectly equals 1000000.002 when using GLdouble (but precision is lost when using GLfloat).

Will I have to do the world space translation outside of OpenGL, possibly using some "bignums" of my own, or is there any trick inside OpenGL for that ?

NB: views are set using GLU or by hand (setting both MODELVIEW and PROJECTION matrixes), results are the same.

Thierry Bernier

01-02-2006, 08:04 AM
Your running in the standard real number precision issues whether float of double

Doubles really don't help too much as Opengl converts them to floats any way

And don't forget the golden rule you never compare real numbers on a computer ( float or doubles ) always test for in equality

There any many many ways to try and reduce the issue with number precision using pengl a search of these forums may help or a straight Google may help

And you have no guarantee on any PC the any real number will perfectly equal a give value

But you are going to have to handle the problem, Opengl itself does not offer you any tools to directly help with the precision issues