POV-Ray : Newsgroups : povray.animations : A sign rotating back and forth. Server Time
17 May 2024 05:12:22 EDT (-0400)
  A sign rotating back and forth. (Message 1 to 9 of 9)  
From: RusHHouR
Subject: A sign rotating back and forth.
Date: 4 May 2006 08:40:00
Message: <web.4459f5224a07a59a47d3ae5e0@news.povray.org>
Hi!

I'm making a simple animation with camera sweeping over the scene.
As usual.

But I wanna go further, and make a sign (see image link below) flap
as if winds were blowing on it.

http://img223.imageshack.us/img223/9836/taggtrad9rh.jpg

Image shows "skylt" rotated at x-10

object {skylt
rotate <-10,0,0>
translate <0.2,3.9,0>}

How would one do to make it flap from rotate x 5 to x -10 continously
through the animation?
Can this be achieved?

Thanks

/RH


Post a reply to this message

From: Chris B
Subject: Re: A sign rotating back and forth.
Date: 4 May 2006 09:39:24
Message: <445a040c$1@news.povray.org>
"RusHHouR" <gee### [at] mailnu> wrote in message 
news:web.4459f5224a07a59a47d3ae5e0@news.povray.org...
> Hi!
>
> I'm making a simple animation with camera sweeping over the scene.
> As usual.
>
> But I wanna go further, and make a sign (see image link below) flap
> as if winds were blowing on it.
>
> http://img223.imageshack.us/img223/9836/taggtrad9rh.jpg
>
> Image shows "skylt" rotated at x-10
>
> object {skylt
> rotate <-10,0,0>
> translate <0.2,3.9,0>}
>
> How would one do to make it flap from rotate x 5 to x -10 continously
> through the animation?
> Can this be achieved?
>
> Thanks
>
> /RH
>

Hi R,

The following simplified example illustrates one way of getting something to 
swing based on the clock variable.
This assumes a 5 second animation as the clock variable passes from 0 to 1 
with a 2 second swing.


// Command Line settings    +kfi0 +kff20    Use 320*240,No AA
camera {location  <2,-0.5,0> look_at <0,-0.5,0> angle 50}
light_source {<30, 10, -300> color rgb 2}
#include "math.inc"

#declare MyClock = clock*5;
#declare SecondsPerCycle = 2; // One complete flap every 2 seconds

// Calculate a number that varies linearly between -1 and +1 over the cycle
#declare CyclePosition = mod(MyClock,SecondsPerCycle)*2-1;

// Apply a sine function to give a value that stays out at the extremes 
longer
#declare CycleFactor = sind(90*CyclePosition);

cylinder {0,-y,0.05 pigment {color rgb <1,1,0>} rotate 
x*(CycleFactor*7.5-2.5)}


Of course a sign wouldn't swing naturaly in wind, because the force varies 
quite a bit as the sign moves, so you might want to add a bias so that it 
stays longer at the far end of the swing than when it's down in the full 
force of the wind. I assume you don't want to get into modelling the exact 
behaviour.

Anyway, hope it gives you some ideas.

Regards,
Chris B.


Post a reply to this message

From: Stephen
Subject: Re: A sign rotating back and forth.
Date: 4 May 2006 10:15:00
Message: <web.445a0baa24781bb4c6b359800@news.povray.org>
"RusHHouR" <gee### [at] mailnu> wrote:
> Hi!
>
> I'm making a simple animation with camera sweeping over the scene.
> As usual.
>
> But I wanna go further, and make a sign (see image link below) flap
> as if winds were blowing on it.
>
> http://img223.imageshack.us/img223/9836/taggtrad9rh.jpg
>
> Image shows "skylt" rotated at x-10
>
> object {skylt
> rotate <-10,0,0>
> translate <0.2,3.9,0>}
>
> How would one do to make it flap from rotate x 5 to x -10 continously
> through the animation?
> Can this be achieved?
>


this.

object {skylt
rotate < 5 - (15*clock),0,0>
translate <0.2,3.9,0>}


If your clock goes from 0.0 to 1.0 this will rotate skylt from +5 degrees to
-10 degrees once during the animation. From there you can build on it. You
can use sin and cos functions with the clock variable.

Stephen


Post a reply to this message

From: RusHHouR
Subject: Re: A sign rotating back and forth.
Date: 4 May 2006 11:30:01
Message: <web.445a1d8f24781bb447d3ae5e0@news.povray.org>
Thank you both!

The later answer is where I am now, basicly.
One swing per total animation 0.0 to 1.0.
I want more like 3-5 swings from 0.0 to 1.0.

The sign will not be in center of camera sweep, just passing for a few
seconds.

Will try the Chris B version, and see what it gives. =)

Thanks again!

/RH


Post a reply to this message

From: Loki
Subject: Re: A sign rotating back and forth.
Date: 4 May 2006 13:00:00
Message: <web.445a32dd24781bb44e3664660@news.povray.org>
"RusHHouR" <gee### [at] mailnu> wrote:
> Thank you both!
>
> The later answer is where I am now, basicly.
> One swing per total animation 0.0 to 1.0.
> I want more like 3-5 swings from 0.0 to 1.0.
>
> The sign will not be in center of camera sweep, just passing for a few
> seconds.
>
> Will try the Chris B version, and see what it gives. =)
>
> Thanks again!
>
> /RH

Why not use a more random looking function?  For example, rotating by an
amount proportional the value returned by a bozo or noise function at a
point dependent on the clock variable.  That might give you a more
wind-like behaviour taking into account the gusty randomness you need, but
would of course be difficult to control if you need the sign to be in a
definite place at a certain time.

L
-


Post a reply to this message

From: RusHHouR
Subject: Re: A sign rotating back and forth.
Date: 5 May 2006 08:55:00
Message: <web.445b4a9424781bb447d3ae5e0@news.povray.org>
"Loki" <nomail@nomail> wrote:
>
> Why not use a more random looking function?  For example, rotating by an
> amount proportional the value returned by a bozo or noise function at a
> point dependent on the clock variable.  That might give you a more
> wind-like behaviour taking into account the gusty randomness you need, but
> would of course be difficult to control if you need the sign to be in a
> definite place at a certain time.
>
> L
> -

Sounds like an idea. But I dont know how to recieve a value from a bozo
function(!?). Im trying to grasp the meaning of sin and cosin atm... =)

Im test rendering with Chris B's code right now. I get the impression that
he was the one who actually understood my question.

Will post linked mpg here. =)


Post a reply to this message

From: RusHHouR
Subject: Re: A sign rotating back and forth.
Date: 6 May 2006 12:00:01
Message: <web.445cc6ee24781bb447d3ae5e0@news.povray.org>
Hmmmm.... Chris! Would you mind helping me a bit more? please...?

http://download.yousendit.com/75D992413B17076C

If i blink in a constant rythm, it looks ok! ;)

Seriously though, what needs to be added to make it move a bit smoother in
both directions? I dont understand this code (which of course bothers me)
so Im a bit afraid of trying to tweak it out of control...

Used:

//------------------------

#include "math.inc"

#declare MyClock = clock*5;
#declare SecondsPerCycle = 1; // One complete flap every 2 seconds

// Calculate a number that varies linearly between -1 and +1 over the cycle
#declare CyclePosition = mod(MyClock,SecondsPerCycle)*2-1;

// Apply a sine function to give a value that stays out at the extremes
longer
#declare CycleFactor = sind(90*CyclePosition);



object {skylt
rotate x*(CycleFactor*7.5-2.5)
translate <0.2,3.9,0>}


//------------------------


Post a reply to this message

From: Chris B
Subject: Re: A sign rotating back and forth.
Date: 6 May 2006 13:23:07
Message: <445cdb7b@news.povray.org>
"RusHHouR" <gee### [at] mailnu> wrote in message 
news:web.445cc6ee24781bb447d3ae5e0@news.povray.org...
> Hmmmm.... Chris! Would you mind helping me a bit more? please...?
>
> http://download.yousendit.com/75D992413B17076C
>
> If i blink in a constant rythm, it looks ok! ;)
>
> Seriously though, what needs to be added to make it move a bit smoother in
> both directions? I dont understand this code (which of course bothers me)
> so Im a bit afraid of trying to tweak it out of control...
>
> Used:
>

Hi,
Ah yes. My apologies. I was in a bit of a hurry at the time and should have 
tested it with a range of values. By coincidence it worked with the first 
values I tried and I just assumed I'd therefore got my maths right (an 
incorrect assumption as it turned out). Also now I've got a bit more time 
I'll try and explain what's going on a little better. (I like your animation 
by the way). The following code should work and is explained below.

// +kfi0 +kff50    Use 320*240,No AA
camera {location  <3.2,4.5,0> look_at <0.2,3.9,0>}
light_source {<30, 10, -300> color rgb 2}
#include "math.inc"

#declare MyClock = clock*5;
#declare SecondsPerCycle = 1; // One complete flap every 1 second
#declare skylt = cylinder {0,-y,0.05 pigment {color rgb <1,1,0>}}

// Calculate a number that varies linearly between -1 and +1 over the cycle
#declare CyclePosition = mod(MyClock,SecondsPerCycle)*2/SecondsPerCycle-1;

// Apply a sine function to give a value that stays out at the extremes
// for longer
#declare CycleFactor = sind(180*CyclePosition);

object {skylt
  rotate x*(CycleFactor*7.5-2.5)
  translate <0.2,3.9,0>
}

Step 1.
The clock variable changes from 0 to 1 in a linear way as POV-Ray renders 
each of the frames you tell it to render. If you use the command line 
options shown at the top of the example above, then POV-Ray will render 51 
frames and the clock passes from 0 to 1 in steps of 0.02.
MyClock is set to clock*5 to represent 5 seconds  for the animation which 
would represent about 10 frames per second.  The value of MyClock therefore 
passes from 0 to 5.

Step 2.
Using mod() gives the remainder after an integer division, so, the result 
passes from 0 to SecondsPerCycle, then starts again at 0 and repeats this 
'MyClock/SecondsPerCycle' times (in this case 5 times).
My first mistake was in forgetting to divide this value by SecondsPerCycle, 
which is needed to give a number that cycles from 0 to 1 and does so 5 times 
during the animation sequence.
Multiplying by 2 and subtracting 1 gives a number that cycles from -1 to 1 
in a linear way.
You could use this value to swing your sign back and forth, but it would 
give abrupt changes at the extremes of the swing, whereas a freely swinging 
pendulum slows down at the top ends of its swing.

Step 3.
A standard representation of a sine wave passes from 0 to -1 up to 1 and 
back down to 0 in the 'y' axis as the 'x' value changes from -180 to +180 
degrees (This was my second mistake where I originally had 90 degrees which 
compensated for the first mistake, but only when the value of SecondPerCycle 
was set to 2).
With a sine wave, for a given linear step in the 'x' direction, the step in 
the 'y' direction varies in a sinusoidal manner taking smaller steps as 'y' 
approaches the extremes (-1 and 1) and larger steps as 'y' passes through 
y=0. This is what you want to use for rotating your sign so that the sign 
moves less between each frame as it nears the extremes of its swing and more 
between each frame as it passes through the middle of the swing.

Step 4.
Multiplying by 7.5 makes the value pass from -7.5 to +7.5 and subtracting 
2.5 gives -10 to +5.

Hope this helps and I hope I didn't make any mistakes this time.
Any questions?  :-)

Regards,
Chris B.


Post a reply to this message

From: RusHHouR
Subject: Re: A sign rotating back and forth.
Date: 6 May 2006 16:45:01
Message: <web.445d0a9424781bb447d3ae5e0@news.povray.org>
Yes! that did the trick!

(Wohoo!) :D

I've also read what you wrote a few times, and it gave me more understanding
of what it excactly is we have done here. Thanks for that too!

(However I shall probably read it again slowly a few times, as the
combination of my POV-Ray, English and Mathematical skills dont quite add
up... ;)

Main thing is; I can let it swing!

A very big THANK YOU to you Chris!

(Will not post more clips atm, because of potential spoil risks ;)


Post a reply to this message

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