POV-Ray : Newsgroups : povray.animations : Math Question : Re: Math Question Server Time
1 Jul 2024 01:56:04 EDT (-0400)
  Re: Math Question  
From: Chris B
Date: 13 Oct 2005 05:12:32
Message: <434e2500$1@news.povray.org>
"Josh" <s### [at] acom> wrote in message news:434e1532@news.povray.org...
> I've got a Key Frame animation utility I've written.
>
> Unfortunately it only works in straight lines, that is to say it 
> calculates the variables for each frame by dividing the starting and 
> ending values by the number of frames.
>
> This is fine but I want to be able to start the movement faster and end it 
> slower, and vice versa, possibly even have it faster at the beginning and 
> and with it slower in the middle.
>
> Example of what I am doing at the moment.
>
> Start Value for Camera X is -100
> End Value for Camera X is 1095
> There are 150 frames, so I increment the Camera X by +7.96 per frame, a 
> straight line.
>
> What formular can I use to have the camera start faster and slow to a 
> halt?
>

It depends what sort of deceleration you want, but one option is to simply 
use a sin function something like:

Camera X =  sin( (FrameCounter-1)*90/149)*1195-100   ## Untested ##

So that, as the FrameCounter goes from 1 to 150 we take the sine of a number 
that goes from 0 to 90. This gives us a number that passes from 0 to 1 in a 
sinusoidal fashion (approaching 1 increasingly slowly) which we can multiply 
by the total distance to travel and finally adjust to start at -100.

Any good?

Chris B.


Post a reply to this message

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