POV-Ray : Newsgroups : povray.advanced-users : Create spline : Re: Create spline Server Time
3 Jul 2024 05:08:13 EDT (-0400)
  Re: Create spline  
From: clipka
Date: 5 Mar 2009 10:35:00
Message: <web.49aff023db4d2f97f567c3de0@news.povray.org>
"twister" <twi### [at] o2pl> wrote:
> Thanks to all of you. create_spline macro works fine as I wanted to work.
> Due to array size I meant number of elements in the array and for now
> dimension_size is enough for me.

To efficiently check the "populated size" of an array, you could use #ifdef in a
binary search manner:

#local iLastKnownPopulated = -1;
#local iFirstKnownUnpopulated = dimension_size(MyArray,1);
#while (iLastKnownPopulated + 1 < iFirstKnownUnpopulated)
  #local iMid = int((iLastKnownPopulated + iFirstKnownUnpopulated)/2);
  #ifdef(MyArray[iCenter])
    #local iLastKnownPopulated = iMid;
  #else
    #local iFirstKnownUnpopulated = iMid;
  #end
#end
#local PopulatedArraySize = iFirstKnownUnpopulated;

(untested draft)


Post a reply to this message

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