POV-Ray : Newsgroups : povray.advanced-users : Animating lengthening splines : Re: Animating lengthening splines Server Time
28 Jul 2024 14:26:45 EDT (-0400)
  Re: Animating lengthening splines  
From: scott
Date: 16 Jun 2005 16:07:05
Message: <42b1dbe9@news.povray.org>
"Chris B" <c_b### [at] btconnectcom> wrote in message
news:42b1bbac$1@news.povray.org
> Here's an adaptation that measures the length of the spline first:
>
> camera { location <0,2,-2> look_at 0 }
> light_source { <-5,30,-10> 1 }
> #declare MySpline =
>  spline {
>    cubic_spline
>    -.25, <0,0,-1>
>    0.00, <1,0,0>
>    0.25, <0,0,1>
>    0.50, <-1,0,0>
>    0.75, <0,0,-1>
>    1.00, <1,0,0>
>    1.25, <0,0,1>
>  }
>
>
> #declare Percentage = 43;
>
> #local ctr = 0;
> #local SplineLength = 0;
> #local OldPoint = MySpline(0);
> #while (ctr <= 1)
>  #local SplineLength = SplineLength +
>  vlength(MySpline(ctr)-OldPoint); #local OldPoint = MySpline(ctr);
>  #local ctr = ctr + 0.0001;
> #end
>
>
> #local ctr = 0;
> #local DistanceTraveled = 0;
> #local OldPoint = MySpline(0);
> #while (DistanceTraveled < Percentage*SplineLength/100)
>  #local DistanceTraveled = DistanceTraveled +
> vlength(MySpline(ctr)-OldPoint);
>  #local OldPoint = MySpline(ctr);
>  sphere {
>    MySpline(ctr),.1
>    pigment { rgb <1-ctr,ctr,0> }
>  }
>  #local ctr = ctr + 0.001;
> #end

Thanks for that.  I have done what you said, but also added a bit in the 
second loop so that it only places a sphere every certain distance.  That 
makes the spheres uniformly spaced (more or less) and saves having 
258725892758 spheres to get the long bits smooth!


Post a reply to this message

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