POV-Ray : Newsgroups : povray.animations : Animation block...acceleration on the x axis. : Re: Animation block...acceleration on the x axis. Server Time
8 May 2024 15:18:00 EDT (-0400)
  Re: Animation block...acceleration on the x axis.  
From: David Wallace
Date: 31 Mar 2009 14:25:38
Message: <49d26022$1@news.povray.org>
RC wrote:
> Hello,
> 
> I know this question is going to be a head slapper but I can't seem to get an
> object to increase in speed. I need this object to increase in speed every x
> clock cycles, so I'm using an if statement. Problem is I can get it to enter
> the 'else' section, but it never returns to my original condition after I reset
> my variable counting to x (num).
> 
>         #declare num = clock*60;
>         //60 being the total number of frames
>         #declare speed = clock;
>         #if (num <= 3)
>               object { Ball
>                 scale 0.7
>                 translate <-5.5, 0, 0>
>                 translate <speed, 0, 0>
>                 #declare num = num + 1;
>                }
>               #debug "speed the same\n"
>         #else
>               #declare speed = speed + 1;
>               #declare num = clock;
>               #debug"speed increased\n"
>         #end
> 
> This is hurting my brain, and I know the answer is staring me down I just can't
> see it. Any input? I have a feeling its related to the declare statements.
> 
> 
Let's simply inject some basic physics here.  Clock runs generally from 
0 to 1 regardless of the number of frames unless changed via the command 
line or INI.  Do this:

// Initial position
#declare x0 = -5.5;
// Initial velocity
#declare v0 = 1;
// Acceleration
#declare acc = 0.45;

// Actual position
#declare xp = x0 + v0*clock + 0.5*acc*clock*clock;

// Object
object { Ball
	scale 0.7
	translate <xp, 0, 0>
}

You can alter the numbers or even make them vectors as desired.


Post a reply to this message

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