POV-Ray : Newsgroups : povray.general : T-less spline macro for P3.5 : Re: T-less spline macro for P3.5 Server Time
5 Aug 2024 16:12:25 EDT (-0400)
  Re: T-less spline macro for P3.5  
From: ingo
Date: 21 Aug 2002 12:06:23
Message: <Xns9271B8E1AE5A9seed7@povray.org>
in news:3D6### [at] skynetbe Fabien Mosen wrote:

> Does anyone knows about a #macro that would do that ?
> 
> 

Fabien,
I'm not sure if this is what you're looking for, as I've never used "the 
other" spline type in MegaPov.
The maco takes an array of points as input, it always expects one point 
before the start of the spline and one point beyond the end of it. The 
t-value will go from ...,0 - 1,...
SplType is a string to set the wanted type of spline (C/c/L/l/N/n/Q/q).


---%<------%<---
#macro BuildSpline(Arr, SplType)
   #local Ds=dimension_size(Arr,1);
   #local Asc=asc(strupr(SplType));
   #if(Asc!=67 & Asc!=76 & Asc!=81) 
      #local Asc=76;
      #debug "\nWrong spline type defined (C/c/L/l/N/n/Q/q), using 
default linear_spline\n"
   #end
   spline {
      #switch (Asc)
         #case (67) //C  cubic_spline
            cubic_spline
         #break
         #case (76) //L  linear_spline
            linear_spline
         #break
         #case (78) //N  linear_spline
            natural_spline
         #break
         #case (81) //Q  Quadratic_spline
            quadratic_spline
         #break
      #end
      #local Add=1/((Ds-2)-1);
      #local J=0-Add;
      #local I=0;
      #while (I<Ds)
         J 
         Arr[I]
         #local I=I+1;
         #local J=J+Add;
      #end
   }      
#end
---%<------%<---

Ingo


Post a reply to this message

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