POV-Ray : Newsgroups : povray.general : evenly spaced points on splines : Re: evenly spaced points on splines Server Time
31 Jul 2024 04:15:53 EDT (-0400)
  Re: evenly spaced points on splines  
From: Jim Charter
Date: 22 May 2008 20:24:28
Message: <48360ebc@news.povray.org>
stevenvh wrote:


this a quick and dirty macro I use:

#macro SmoothSpline( Spline, Grain )
//regularizes the spline definition so
//the distance along the spline will be
//more proportional to the clock value

//first measure the input spline
         #local TL=0;
         #local Ptr=1;#while(Ptr<=Grain)
                 #local TL=
                         TL+vlength( Spline(Ptr/Grain)
                         -Spline((Ptr-1)/Grain) );
         #local Ptr=Ptr+1;#end

//now redefine the spline
         #local L=0;
         spline { 

                 natural_spline
                 0 Spline(0)
                 #local Ptr=1;#while(Ptr<=Grain)
                         #local L=
                         L+vlength( Spline(Ptr/Grain)
                         -Spline((Ptr-1)/Grain) );

                         L/TL Spline(Ptr/Grain)
                 #local Ptr=Ptr+1;#end
         }

#end


Post a reply to this message

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