|
|
Gordon wrote:
>
> Hi All,
>
> I got this the other day and after bashing on my code for a couple of hours
> found that it was what appears to be a POVRay bug.
>
> I have a file that uses the clock value for animation. I set the animation
> to use 10 frames. I multiply clock by 4 for my animation. I then take
> modulus 1.0 to get the fractional part of the number only. The problem is
> that at frame 5 the value is 1.0 (ie Y=mod(clock*4,1.0); results in Y=1.0).
> Now when I did maths, mod(x,1.0) can NEVER be equal to 1.0, what gives?
>
> After some investigation, I found that the value for the clock at frame 5 is
> around 2.00000000000000001! This still doesn't explain how the mod()
> function gives me 1.0 as an answer though, so perhaps there are two bugs
> here, one in the calculation of clock values, and one in the mod function.
>
> Has anyone else seen this? Does anyone have a way to work around this error
> that will work regarless of the number of frames? ( If I use an odd number
> of frames, the problem goes away )
I found the same problem with imprecision in the clock variable while
working on my latest IRTC entry; it was causing things to happen a
frame late. I put the following code at the beginning:
#declare Frame=floor(clock*24+.001); // 24 frames per second animation
#declare Clock=Frame/24; // get actual clock value
I then use the Clock label instead of clock.
Regards,
John
Post a reply to this message
|
|