POV-Ray : Newsgroups : povray.advanced-users : struggle with splines : Re: struggle with splines Server Time
6 Oct 2024 13:05:23 EDT (-0400)
  Re: struggle with splines  
From: Random Pete
Date: 4 Oct 2006 00:10:00
Message: <web.45233402d128f9369cf609e10@news.povray.org>
"Chrisir" <nomail@nomail> wrote:
> Hello!
>
> I am just struggling with splines here.
> I have one spline then should go from P1
> to P2 (exactly), being modified by M1, M2 and M3.

You might find it useful to write the code like this:


#macro MSpline(P1,P2,M1,M2,M3)
  spline {
    cubic_spline
    -1,M1
     0,P1
     0.5,M2
     1,P2
     2,M3
  }
#end  // end of macro

#macro ObjSpline(Obj,Size,c1,c2,Spline) // c1 and c2 is for color.
        #local ctr = 0;

        #while (ctr <= 1)
                object {
                        Obj
                        scale Size
                        translate Spline(ctr)
                        pigment { rgb c1*(1-ctr) + c2*(2-ctr) }
                }
                #local ctr = ctr + 0.01;
        #end   // end of while
#end  // end of macro

#declare MSpline1 = MSpline(coords...);
ObjSpline(sphere{0,1},0.05,rgb<1,0,0>,rgb<0,1,0>,MSpline1)



....This way the ObjSpline macro can be used to distribute *any* object along
the spline's path. You could add additional parameters such as the number of
objects to distribute along the spline, and you could also make the function
reorient the object to point in the direction of the spline.


Post a reply to this message

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