POV-Ray : Newsgroups : povray.general : To Mike Williams on SweepMesh : Re: To Mike Williams on SweepMesh Server Time
1 Aug 2024 08:21:15 EDT (-0400)
  Re: To Mike Williams on SweepMesh  
From: Mike Williams
Date: 31 Dec 2005 12:14:50
Message: <xctvIGA$xrtDFwIg@econym.demon.co.uk>
Wasn't it Greg M. Johnson who wrote:
>Mike, 
>I was tinkering with some applications of this code.  I think that it says
>that the spline will be evaluated "between control points 0 and 1".  I
>think however you're also doing it between the second and (n-1)th entry in
>the code-- i.e., the code forces one to do a cubic spline.   I was doing a
>natural_spline and found that the last entry was always missing, and I
>think this is the reason.  I'm guessing one could change just a few
>keystrokes in the file and be okay, but I'm wondering if you could help me
>out before my brain explodes.  

It does what it says. The spline is evaluated between the control points
that have values 0.0 and 1.0. It's not necessary to actually specify
control points at those locations, as long as the spline is validly
defined over the range 0.0 to 1.0.

The code accepts any type of spline.

#declare Track = 
  spline {
    natural_spline
    0,  <10,1,0>,
    0.5 <0,0,0>,    
    1, <10,-3,0>
  }

For cubic splines there needs to be extra control points outside the 0-1
range because a cubic_spline is not validly defined in the first and
last sector.

#declare Track = 
  spline {
    cubic_spline
    -1, <12,2,0>,
    0,  <10,1,0>,
    0.5 <0,0,0>,    
    1, <10,-3,0>,
    2, <12,-5,0>
  }

If you add control points after 1.0 in a natural or linear spline they
will be ignored. 

#declare Track = 
  spline {
    natural_spline
    0,  <10,1,0>,
    0.5 <0,0,0>,    
    1, <10,-3,0>,
    2, <12,-5,0>        // this point is ignored
  }

You can check that the macro is doing the right thing by plotting some
spheres along the spline, like this:

#declare A=0;
#while (A<1.0)
  sphere{ Track(A),0.1 pigment {rgb x}}
  #declare A=A+0.02;
#end

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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