POV-Ray : Newsgroups : povray.general : Clock intervals : Re: Clock intervals Server Time
1 May 2024 17:35:53 EDT (-0400)
  Re: Clock intervals  
From: Mike Horvath
Date: 17 Jul 2018 20:51:31
Message: <5b4e8f13$1@news.povray.org>
Changing the speed is a neat idea!

Mike


On 7/17/2018 8:08 PM, dick balaska wrote:
> On 07/17/2018 05:36 PM, Mike Horvath wrote:
>> I want to be able to tie a variable to the clock value, but only for
>> certain portions.
>>
>> For example, the variable should be equal to 0 before the clock is 0.3,
>> and equal to one after the clock is equal to 0.6. In between 0.3 and 0.6
>> the clock should interpolate from 0 to 1.
>>
>> How would I do this using a macro? Thanks.
>>
>>
>> Mike
> 
> This might be the single most common thing I do in my anim.
> 
> I never hardcode 0.3 in the code. Because you will likely want to tweak
> it [1] and here you only have to change it in one place.
> 
> #declare Start=0.3;
> #declare End = 0.6;
> 
> #switch (myclock)
>    #range (0,Start)
>      #declare Out=0;
>      #break
>    #range(Start, End)
>      #declare Out=AniSegment(Start,End);
>      #break
>    #range(End,1)
>      #declare Out=1;
>      #break
> #end
> 
>
///////////////////////////////////////////////////////////////////////////////////////////////////
> // Animate this segment of the clock from 0 to 1
> #macro AniSegment(_start, _end)
>    ((myclock-_start)/(_end-_start))
> #end
> 
> 
> Additionally, I like to add acceleration/deceleration to the move. So:
>    #range(Start, End)
>      #local F=AniSegment(Start,End);
>      #declare Out=Curve0(F);
>      #break
> 
> where
> 
> #declare pi2=(pi*2);
> 
>
///////////////////////////////////////////////////////////////////////////////////////////////////
> // Curves: see http://www.buckosoft.com/~dick/pov/curves/
> #macro Curve0(_i)
>    (0.5-(cos(_i/2*pi2)/2))
> #end
> 
> 
> [1] This smells like you really want
>      #declare Start=1/3;
>      #declare End=2/3;
>


Post a reply to this message

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