NaNs Just Don't Get No Respect

Sean Cavanaugh WorksOnMyMachine at gmail.com
Mon Aug 20 00:22:11 PDT 2012


On 8/20/2012 12:41 AM, Nick Sabalausky wrote:
> On Sun, 19 Aug 2012 01:21:03 -0500
> Sean Cavanaugh<WorksOnMyMachine at gmail.com>  wrote:
>>
>> Nobody knows how floats work, without being locked in a closet for a
>> at least a week and told to change their doubles back into floats and
>> fix their code, since thats where 99% of precision problems actually
>> come from.
>>
>
> Sorry, I don't understand, where are you saying 99% of precision
> problems come from?
>

Chaining algorithms together without regard to how the floats are 
propagated through the system.  Also, accumulating lots of values with 
addition and subtraction can be problematic, as can subtracting two 
values to near-zero values also leaves you with a most of the error.

There is a pretty classic example in 3d graphics: the transform from 
object space to world space to projection space.  Even if these matrices 
are combined, your geometry can be transformed a very large distance 
from the world origin and lose a lot of precision in the process.  The 
way to fight this is to use camera instead of world space as much as 
possible.  If you don't do this all the vertices on all the meshes in 
your world snap to different values at varying rates when they move or 
the camera moves, causing one of the main forms of z-fighting.   Plus 
the further you get from your world origin the worse things get, which 
makes building something on the scale of an open-world game rather 
difficult.



More information about the Digitalmars-d-announce mailing list