POV-Ray : Newsgroups : povray.animations : Animation block...acceleration on the x axis. : Re: Animation block...acceleration on the x axis. Server Time
27 Apr 2024 04:14:26 EDT (-0400)
  Re: Animation block...acceleration on the x axis.  
From: RC
Date: 24 Feb 2009 10:55:00
Message: <web.49a417c221b0f15ae1acfc5e0@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> I think that you are using the wrong approach for the effect you are
> trying to achieve.
>
>   What you probably want is a function which gives you the position of
> the object as a function of time. We could do this literally with a
> function, like this:
>
> #declare ObjectXPosition = function(t) { <a function of t here> };
> object { Ball translate <ObjectXPosition(clock*60), 0, 0> }
>
>   Now it's only a question of writing the proper implementation for that
> "<a function of t here>". If you wrote it like this:
>
> #declare ObjectXPosition = function(t) { 0 };
>
> then you would have a static object at x = 0, which doesn't move. If you
> wrote this:
>
> #declare ObjectXPosition = function(t) { t };
>
> then the object would move at a fixed speed, as its x coordinate would be
> linear with respect to time. If you wrote this:
>
> #declare ObjectXPosition = function(t) { t*t };
>
> now the speed of the object doubles for each unit of time. In other words,
> you get a constant acceleration. You can get a slower acceleration by using
> powers smaller than 2, eg:
>
> #declare ObjectXPosition = function(t) { pow(t, 1.5) };
>
>   You said that you wanted speed which changes depending on the time.
> In other words, if clock*60 <= 3, the speed is linear, but for larger
> values it's accelerating. Creating one single function to do this becomes
> quite complicated, but you can achieve the same effect by using two
> functions for those two cases, and adding them appropriately, like this:
>
> #declare LinearSpeed = function(t) { t };
> #declare AcceleratingSpeed = function(t) { pow(t, 1.5) };
>
> #declare num = clock*60;
> #declare ObjectX = LinearSpeed(num);
> #if(num > 3)
>   #declare ObjectX = ObjectX + AcceleratingSpeed(num - 3);
> #end
>
>   (Note that the parameter to the latter function has to be shifted so
> that it starts from 0 forwards.)
>
> --
>                                                           - Warp
Ok, so I'm trying this out, but I find I'm still hitting the same fundamental
block. "In other words, if clock*60 <= 3, the speed is linear, but for larger
> values it's accelerating." Not quite. I want the speed to increase lets say every
three frames.
So frames 1->3 = t 4->6 = t+1 7->9 = t+2 etc. At what point in the code would I
include a variable that changes the "function of t" value every three frames?
My apologies, I'm not a 3D animator nor am I much of a programmer. ;(


Post a reply to this message

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