POV-Ray : Newsgroups : povray.advanced-users : Animating lengthening splines : Re: Animating lengthening splines Server Time
28 Jul 2024 14:18:45 EDT (-0400)
  Re: Animating lengthening splines  
From: Chris B
Date: 16 Jun 2005 12:22:23
Message: <42b1a73f$1@news.povray.org>
"scott" <sco### [at] spamcom> wrote in message news:42b19b1b$1@news.povray.org...
> OK, this is what I want to do:
>
> I want to define a spline (or set of points), then be able to say "draw
43%
> of this spline" or whatever.  It would then draw the first 43% of this
> spline, and not the rest.  I'm going to use this in an animation to show a
> spline gradually getting longer at constant speed.
>
> Now, this is a bit trickier than it sounds, because the spline will not be
> equal lengths between each point, and because i'll be using cubic or
> something, the spacing between the points will not be linear.
>
> I tried to make a macro that stepped through the spline and measured the
> length to work out where the "cut-off" point was, but to make it accurate
> enough I had to use a really small step size, and it took forever to
parse.
>
> Anyone have any clever ideas? Or better yet, some code, or some weird
> built-in function I'm missing?
>
>

Well I think this is a clever idea, but I'm willing to stand corrected if it
turns out to be a dumb one :-)
Isn't what you want virtually what the example in the POV-Ray help does
with:

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 ctr = 0;
#while (ctr < 1)
  sphere {
    MySpline(ctr),.25
    pigment { rgb <1-ctr,ctr,0> }
  }
  #declare ctr = ctr + 0.01;
#end
The points themselves wouldn't have to be uniformly spaced, but you would
need to be able to identify the lengths of each segment and set the values
given when defining the spline to be proportional to those lengths, then you
could use #while (ctr < 0.43) to give you a spline that's 43% of the total
length.You'd need to adjust the increment to give you smooth looking line. I
tried the above with 0.001 instead of 0.01 and it looked pretty smooth to
me.Regards,Chris.


Post a reply to this message

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