POV-Ray : Newsgroups : povray.bugreports : Clock Bug? Server Time
23 Dec 2024 07:50:35 EST (-0500)
  Clock Bug? (Message 1 to 2 of 2)  
From: Gordon
Subject: Clock Bug?
Date: 18 Feb 1999 00:09:52
Message: <36cba0a0.0@news.povray.org>
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 )

Regards,
Gordon
<gor### [at] hotmailcom>


Post a reply to this message

From: John VanSickle
Subject: Re: Clock Bug?
Date: 24 Apr 1999 13:43:51
Message: <3721F681.6FC1DA7@erols.com>
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

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