POV-Ray : Newsgroups : povray.advanced-users : Create spline : Re: Create spline Server Time
3 Jul 2024 04:53:18 EDT (-0400)
  Re: Create spline  
From: twister
Date: 3 Mar 2009 04:25:01
Message: <web.49acf63adb4d2f97c9ee64130@news.povray.org>
I have created such a #macro:

#macro createSpline(arr, arrSize, name)
  #local length = 0;
  #local i = 0;
  #while(i < arrSize - 1)
    #local length = length + vlength(arr[i+1] - arr[i]);
    #local i = i + 1;
  #end
  #local overallLength = length;
  #local length = 0;
  #local i = 0;
  #local sp = spline {
    natural_spline
    0.00, arr[0],
    #while(i < arrSize - 1)
      #local length = length + vlength(arr[i+1] - arr[i]);
      length/overallLength, arr[i+1],
      #local i = i + 1;
    #end
    1.00, arr[arrSize - 1]
  }
  #declare name = sp;
#end

So I can use it in this way:
#declare new_spline = 0;
createSpline(myArr, 5, new_spline)
//here I have new_spline filled with spline object

But my intention is to create a #macro that returns spline by value, not by
parameter as above. I could then use my #macro in this way:

#declare new_spline = createSpline(myArr, 5);
//where myArr is an array with points defining a curve

Question 2: Is there any way (other than using #ifdef command) to check the size
of an array?

Best regards,
twister


Post a reply to this message

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