POV-Ray : Newsgroups : povray.general : Blender Vs PovRay : Re: Blender Vs PovRay Server Time
31 Oct 2024 21:27:12 EDT (-0400)
  Re: Blender Vs PovRay  
From: Nicolas George
Date: 26 Oct 2008 08:45:52
Message: <49046680$1@news.povray.org>
Nicolas Alvarez  wrote in message <4903699f@news.povray.org>:
> It's mainly relevant if you loop thousands of times. With 100 iterations
> it's not a big problem :)

Quite the contrary, with this code, there may be problems even for a very
small number of iterations.

For example, consider the following code:

#local n = 10;
#local t = 0;
#while(t < 1)
  #local t = t + 1/n;
#end

and the same with n = 11. It happens that the float value for 1/10 is
slightly smaller than the exact value 1/10, while the float value for 1/11
is slightly greater than the exact value for 1/11. The result is that both
loops make 11 iterations.

This issue can be fixed by using a float-friendly bound, as suggested
earlier by someone: t < 1 + dt / 2 or t < 1 - dt / 2, depending on whether
the loop is supposed to be inclusive or not.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.