POV-Ray : Newsgroups : povray.animations : Animation with sine waves? Server Time
13 Aug 2026 05:37:05 EDT (-0400)
  Animation with sine waves? (Message 1 to 9 of 9)  
From: Sir
Subject: Animation with sine waves?
Date: 23 Jul 2026 00:35:00
Message: <web.6a619842b7fdf4e0e541bb4fe358f448@news.povray.org>
Hello POV-Ray Users!

So, i was rendering an animation of a metronome whose pendulum swings back and
forth between a specific angle and its negative.

Here's how I did it:

#declare maxangle = 35;
#declare actangle = maxangle * sin( clock * 4 ) * cos( clock * 4 );

polygon {
5,
<-.06,0>, <-.06,2.6>, <.06,2.6>, <.06,0>, <-.06,0>
         texture{ Chrome_Metal
                  // normal { bumps 0.5 scale 0.05 }
                  // finish { phong 1 }
                } // end of texture ---------------------------
    translate <0,0,0>
    rotate <0,0,clock*actangle>
    translate <0,.3,-.8>

   }
}
object { metronome
scale .5 }

This is not the complete scene, just the pendulum, which is a polygon that
rotates (maxangle value).

(I'm not an experienced user, and I don't know much about trigonometry and stuff
like that, srry.)

However, the pendulum doesn't swing back and forth constantly (as it should);
instead, it moves a very short distance at the beginning of the animation, and
as the animation progresses, the distance it travels increases until it exceeds
the angle that had been set (or so I think) as the maximum.

If anyone knows what's going on and how to fix it, I would really appreciate
it if you could share your knowledge with me.

Thanks!

(sorry if my english is bad, most of this post was translated)

- S I R ?


Post a reply to this message

From: ingo
Subject: Re: Animation with sine waves?
Date: 23 Jul 2026 01:35:00
Message: <web.6a61a77230cd75d17bac71e8ffb8ce3@news.povray.org>
"Sir" <fra### [at] jaliscoedumx> wrote:

> #declare actangle = maxangle * sin( clock * 4 ) * cos( clock * 4 );
> [...]
>     rotate <0,0,clock*actangle>

Didn't analyse the full thing but noticed the clock as well in actangle as in
rotate again. So you animate the animation, removing the clock from rotate might
do the trick?

ingo


Post a reply to this message

From: Bald Eagle
Subject: Re: Animation with sine waves?
Date: 23 Jul 2026 06:10:00
Message: <web.6a61e78c30cd75dd1d09a9825979125@news.povray.org>
"ingo" <nomail@nomail> wrote:
> "Sir" <fra### [at] jaliscoedumx> wrote:
>
> > #declare actangle = maxangle * sin( clock * 4 ) * cos( clock * 4 );
> > [...]
> >     rotate <0,0,clock*actangle>
>
> Didn't analyse the full thing but noticed the clock as well in actangle as in
> rotate again. So you animate the animation, removing the clock from rotate might
> do the trick?
>
> ingo

Also, why is sin getting multiplied by cos?
I would just use cos to oscillate between 1 and -1.

- BE


Post a reply to this message

From: kurtz le pirate
Subject: Re: Animation with sine waves?
Date: 25 Jul 2026 05:53:25
Message: <6a648795$1@news.povray.org>
On 23/07/2026 06:30, Sir wrote:
> 
> Hello POV-Ray Users!
> 
> So, i was rendering an animation of a metronome whose pendulum swings back and
> forth between a specific angle and its negative.
> 

Hello 'Sir Francisco',

I think you're making things harder on yourself....


For exemple :

// 50 degrees -> +/- 25 deg or something else, of course
#declare Amplitude = 50;
#declare HalfAmplitude = Amplitude*0.50;


Object to animate is "Object"

object {
   Object
   rotate sin(clock*tau)*HalfAmplitude*z
   }

'clock' from 0.0 to 1.0


In this exemple, oscillations is around z-axis.

I hope this helps...




-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message


Attachments:
Download 'metronome.mp4.dat' (45 KB)

From: S I R ?
Subject: Re: Animation with sine waves?
Date: 28 Jul 2026 23:25:00
Message: <web.6a69725e30cd75d7f56ebe5e3a3be07@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "ingo" <nomail@nomail> wrote:
> > "Sir" <fra### [at] jaliscoedumx> wrote:
> >
> > > #declare actangle = maxangle * sin( clock * 4 ) * cos( clock * 4 );
> > > [...]
> > >     rotate <0,0,clock*actangle>
> >
> > Didn't analyse the full thing but noticed the clock as well in actangle as in
> > rotate again. So you animate the animation, removing the clock from rotate might
> > do the trick?
> >
> > ingo
>
> Also, why is sin getting multiplied by cos?
> I would just use cos to oscillate between 1 and -1.
>
> - BE

I don't really know why, i just messed up with something i don't even
know about :(

Also, thanks for your time and patience!

- S I R ?


Post a reply to this message

From: S I R ?
Subject: Re: Animation with sine waves?
Date: 28 Jul 2026 23:30:00
Message: <web.6a69731130cd75d7f56ebe5e3a3be07@news.povray.org>
"ingo" <nomail@nomail> wrote:
> "Sir" <fra### [at] jaliscoedumx> wrote:
>
> > #declare actangle = maxangle * sin( clock * 4 ) * cos( clock * 4 );
> > [...]
> >     rotate <0,0,clock*actangle>
>
> Didn't analyse the full thing but noticed the clock as well in actangle as in
> rotate again. So you animate the animation, removing the clock from rotate might
> do the trick?
>
> ingo

Sorry, i didn't knew what i was doing

- S I R ?


Post a reply to this message

From: S I R ?
Subject: Re: Animation with sine waves?
Date: 28 Jul 2026 23:40:00
Message: <web.6a69750e30cd75d7f56ebe5e3a3be07@news.povray.org>
kurtz le pirate <kur### [at] freefr> wrote:
> On 23/07/2026 06:30, Sir wrote:
> >
> > Hello POV-Ray Users!
> >
> > So, i was rendering an animation of a metronome whose pendulum swings back and
> > forth between a specific angle and its negative.
> >
>
> Hello 'Sir Francisco',
>
> I think you're making things harder on yourself....
>
>
> For exemple :
>
> // 50 degrees -> +/- 25 deg or something else, of course
> #declare Amplitude = 50;
> #declare HalfAmplitude = Amplitude*0.50;
>
>
> Object to animate is "Object"
>
> object {
>    Object
>    rotate sin(clock*tau)*HalfAmplitude*z
>    }
>
> 'clock' from 0.0 to 1.0
>
>
> In this exemple, oscillations is around z-axis.
>
> I hope this helps...
>
>
>
>
> --
> kurtz le pirate
> compagnie de la banquise

Thanks! i tried it and it worked!
If you don't mind, could you explain to me how it works?

- S I R ?


Post a reply to this message

From: Bald Eagle
Subject: Re: Animation with sine waves?
Date: 29 Jul 2026 06:45:00
Message: <web.6a69d8ce30cd75dd1d09a9825979125@news.povray.org>
"S I R ?" <fra### [at] jaliscoedumx> wrote:
> kurtz le pirate <kur### [at] freefr> wrote:

> > // 50 degrees -> +/- 25 deg or something else, of course
> > #declare Amplitude = 50;
> > #declare HalfAmplitude = Amplitude*0.50;

You want the pendulum to swing over a certain amount on both sides.
kurtz defines the included angle as "Amplitude" and then takes half of that as
the amount it swings to either side.

> > Object to animate is "Object"
> >
> > object {
> >    Object
So now he places the Object in the scene, and to rotate it in the animation, he
creates an equation using the clock variable.

if you point at your screen, your arm an finger are in the direction of the z
axis.  So rotating around z rotates things in the plane of your screen.
By how much?
Well the max is "HalfAmlitude".
And we want to go from 0 to HalfAmplitude to 0 to -HalfAmplitude to 0 to .....

A circle is 2*pi radians around in angular units. (tau = 2*pi)
plotting sin on a unit circle goes from 0 to 1 to 0 to -1 to 0 to ....

So as the clock variable increases from 0 to 1, we take that and multiply it by
tau.  That gives us a value that goes from 0 to tau.
Taking the sin of that gives us a value that goes from 0 to 1 to 0 to -1 to 0 to
.....
then multiplying that by HalfAmplitude gives us a value that goes from 0 to
HalfAmplitude to 0 to -HalfAmplitude to 0 to .....
and of course we need a vector to pass to "rotate", and so we multiply by z

> >    rotate sin(clock*tau)*HalfAmplitude*z
> >    }
> >
> > 'clock' from 0.0 to 1.0


Post a reply to this message

From: kurtz le pirate
Subject: Re: Animation with sine waves?
Date: 30 Jul 2026 04:13:44
Message: <6a6b07b8$1@news.povray.org>
On 29/07/2026 12:41, Bald Eagle wrote:
> "S I R ?" <fra### [at] jaliscoedumx> wrote:
>> kurtz le pirate <kur### [at] freefr> wrote:
> 
>>> // 50 degrees -> +/- 25 deg or something else, of course
>>> #declare Amplitude = 50;
>>> #declare HalfAmplitude = Amplitude*0.50;
> 
> You want the pendulum to swing over a certain amount on both sides.
> kurtz defines the included angle as "Amplitude" and then takes half of that as
> the amount it swings to either side.
> 
>>> Object to animate is "Object"
>>>
>>> object {
>>>     Object
> So now he places the Object in the scene, and to rotate it in the animation, he
> creates an equation using the clock variable.
> 
> if you point at your screen, your arm an finger are in the direction of the z
> axis.  So rotating around z rotates things in the plane of your screen.
> By how much?
> Well the max is "HalfAmlitude".
> And we want to go from 0 to HalfAmplitude to 0 to -HalfAmplitude to 0 to .....
> 
> A circle is 2*pi radians around in angular units. (tau = 2*pi)
> plotting sin on a unit circle goes from 0 to 1 to 0 to -1 to 0 to ....
> 
> So as the clock variable increases from 0 to 1, we take that and multiply it by
> tau.  That gives us a value that goes from 0 to tau.
> Taking the sin of that gives us a value that goes from 0 to 1 to 0 to -1 to 0 to
> .....
> then multiplying that by HalfAmplitude gives us a value that goes from 0 to
> HalfAmplitude to 0 to -HalfAmplitude to 0 to .....
> and of course we need a vector to pass to "rotate", and so we multiply by z
> 
>>>     rotate sin(clock*tau)*HalfAmplitude*z
>>>     }
>>>
>>> 'clock' from 0.0 to 1.0
> 


Perfect BE. I couldn't have said it better myself


-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message

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