POV-Ray : Newsgroups : povray.general : Dumb clock animation question : Re: Dumb clock animation question Server Time
19 Apr 2024 11:05:22 EDT (-0400)
  Re: Dumb clock animation question  
From: Tor Olav Kristensen
Date: 19 Feb 2019 09:45:00
Message: <web.5c6c15c330cdf982a48ba9b60@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> On 2/17/2019 7:27 AM, Tor Olav Kristensen wrote:
> > #macro MacroName(StartTime, EndTime)
> >
> >      #local R = (clock - StartTime)/(EndTime - StartTime);
> >      #local S = min(max(0, R), 1);
> >
> >      S
> >
> > #end // macro MacroName
>
> What do you think would be a good way to gradually speed up and then
> slow down the motions using this macro? I'm thinking it would require a
> sine wave (or some other bell curve), but am not sure how to apply it.

If you want to use a simple trigonometric function then I recommend using a
cosine wave, like this:


#macro MacroName(StartTime, EndTime)

    #local R = (clock - StartTime)/(EndTime - StartTime);
    #local S = min(max(0, R), 1)*pi;
    #local T = (1 - cos(S))/2;

    T

#end // macro MacroName


Now S will vary between 0 and +pi. cos(S) will vary between +1 and -1. And T
will vary between 0 and +1.

https://upload.wikimedia.org/wikipedia/commons/d/d2/Sine_and_Cosine.svg

--
Tor Olav
http://subcube.com
https://github.com/t-o-k/


Post a reply to this message

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