POV-Ray : Newsgroups : povray.animations : Spline-based animation Server Time
23 Nov 2024 12:24:37 EST (-0500)
  Spline-based animation (Message 1 to 3 of 3)  
From: HelveticaFanatic
Subject: Spline-based animation
Date: 26 Sep 2008 21:35:00
Message: <web.48dd8d8f7cae7aecb6cdb4fd0@news.povray.org>
How can I ensure that a camera moving along a spline for an animation will go at
the correct speed? I'm using natural splines and can't seem to get spacing
right. I wrote a script to check the spline between different clock points and
divide the difference, but then then I wanted it to return the midpoints which
are really off from the actual midpoints. What can I do? Thanks.


Post a reply to this message

From: Adam
Subject: Re: Spline-based animation
Date: 7 Oct 2008 06:13:34
Message: <48eb364d@news.povray.org>
HelveticaFanatic wrote:

> How can I ensure that a camera moving along a spline for an animation will
> go at the correct speed? I'm using natural splines and can't seem to get
> spacing right. I wrote a script to check the spline between different
> clock points and divide the difference, but then then I wanted it to
> return the midpoints which are really off from the actual midpoints. What
> can I do? Thanks.

Err. I don't know. 

Perhaps use a separate linear camera-position spline. 
Or interpolate a cam-pos from those two splines. 
Or have a 2nd spline as a correction factor to 
subtract from the spline you're using. 

Mmm. I'm not sure.


Post a reply to this message

From: Chris B
Subject: Re: Spline-based animation
Date: 7 Oct 2008 07:52:29
Message: <48eb4d7d$1@news.povray.org>
> HelveticaFanatic wrote:
>
>> How can I ensure that a camera moving along a spline for an animation 
>> will
>> go at the correct speed? I'm using natural splines and can't seem to get
>> spacing right. I wrote a script to check the spline between different
>> clock points and divide the difference, but then then I wanted it to
>> return the midpoints which are really off from the actual midpoints. What
>> can I do? Thanks.

I'd suggest taking small bites along the spline, use vlength() on the 
difference between two successing points and keep a cumulative total of the 
distance travelled from the start of the spline. Use that distance in your 
camera speed calculations.

For example, to get a constant speed

// +kfi0 +kff10
camera {location <0,0,-10> look_at 0 }
light_source {<-10,20,50>, rgb 4}

#declare MySpline = spline {
    cubic_spline
    -.25, <-1, 0, 0>
    0.00, < 3, 0, 0>
    0.10, < 3, 3, 0>
    0.50, <-3, 3, 0>
    0.75, <-2,-1,-3>
    1.00, < 2,-1,-3>
    1.25, < 0, 0, 1>
}

#declare FinalFrameDistance = 25;
#declare ThisFrameDistance = clock * FinalFrameDistance;
// Initialise some working variables
#declare CumulativeDistance = 0;
#declare SplineIndex = 0;
#declare ThisPoint = MySpline(0);
#declare LastPoint = MySpline(0);
// Loop round till we're the right distance through the spline
#while (CumulativeDistance<ThisFrameDistance & SplineIndex<=1)
   #declare ThisPoint = MySpline(SplineIndex);
  // Add the length of this little bite of the spline
   #declare CumulativeDistance = CumulativeDistance + 
vlength(ThisPoint-LastPoint);
   #declare LastPoint = ThisPoint;
   #declare SplineIndex = SplineIndex + 0.001;
#end

sphere {ThisPoint,0.2 pigment {rgb <1,0,0>}}

or, for a constant acceleration:

#declare Acceleration = 40;
#declare AverageSpeed = Acceleration*clock/2;
#declare ThisFrameDistance = AverageSpeed*clock;

Regards,
Chris B.


Post a reply to this message

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