POV-Ray : Newsgroups : povray.advanced-users : objects along a curve... ?! : Re: objects along a curve... ?! Server Time
28 Jul 2024 22:28:53 EDT (-0400)
  Re: objects along a curve... ?!  
From: ABX
Date: 25 Jul 2003 09:50:08
Message: <k6d2iv0uah08bme52unnsh1ugh34nfrq8s@4ax.com>
On Fri, 25 Jul 2003 15:34:34 +0200, "_Light_Beam_" <s.f### [at] tiscalifr> wrote:
> Hello,
>    How to place objects along a curve with same distance between them ?
>    Thx.

I hope this example will help you:

#include "transforms.inc"
#include "shapes.inc"
#include "strings.inc"

#macro Time_To_Length_Converter(Spline,Min,Max,Accuracy)
  #local Conversion=function{spline{
    #local Last=Spline(Min);
    #local Length=0;
    #local C=Min;
    #while (C<=Max)
      #local C=min(C,Max);
      #local Point=Spline(C);
      #local Length=Length+vlength(Point-Last);
      #local Last=Point;
      C , <1,0,0>*Length
      #local C=C+Accuracy;
    #end
  }};
  function(T){Conversion(T).x}
#end

#macro Spline_With_Linear_Movement(Spline,Min,Max,Accuracy)
  spline{
    #local Last=Spline(Min);
    #local Length=0;
    #local C=Min;
    #while (C<=Max)
      #local C=min(C,Max);
      #local Point=Spline(C);
      #local Length=Length+vlength(Point-Last);
      #local Last=Point;
      Length , Point+<0,0,0>
      #local C=C+Accuracy;
    #end
  }
#end

#declare MySpline = spline {
   cubic_spline
   -1,<-1,1,0>,
   0,<0,1,0>,
   0.3, <2,0.7,-2>,
   0.6,<3,-0.8,-3>,
   0.85,<0,-0.8,-3.5>,
   1,<-1,-0.8,-3.72>,
   1.1,<-2,-0.8,-3.75>
  }

#declare MySplineLinear = Spline_With_Linear_Movement(MySpline,0,1,0.001);
#declare f_MySplineLength = Time_To_Length_Converter(MySpline,0,1,0.001);
#declare MySplineLength = f_MySplineLength(1);

#declare MyObject = sphere{0 .1 pigment{rgb 1}};

#declare Step=MySplineLength/30;

#declare All=union{
  #declare Count=0;
  #while (Count<=MySplineLength-Step)
    object {
      MyObject
      pigment { rgb <1,.3,.7>}
      Spline_Trans(MySplineLinear, Count, y, 0.1, 0.1)
    }
    #declare Count=Count+Step;
  #end
  rotate x*90
}

object{
  Center_Object(All,1)
  translate z*5
}

background{1}
light_source{y*100 1}

ABX


Post a reply to this message

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