|
![](/i/fill.gif) |
Paul Bourke wrote:
> Is it possible to use more interesting user defined float functions
> in an isosurface?
>
> When defining the function for an isosurface I would lke to be able
> to use #while loops, for example, to compute a series to some specified
> precision.
>
> Direct email replies welcome.
In POV-Ray 3.6 (or was it only 3.6.1, I don't remember for sure, I tested
with 3.7 beta), real recursive functions work as an experimental feature.
You still get a possible error reported, but possible errors are non-fatal,
so the parser does continue. Thus, this should work:
#declare f = function(n) { select(n - 2.01, 1, f(n - 1) + f(n - 2)) }
#declare n = 1;
#while(n < 20)
#debug str(f(n), 0, 0)
#debug "\n"
#declare n = n + 1;
#end
As far as declaring variables inside functions is concerned (as others have
mentioned), sum and prod "declare" an iteration variable, and thus with sum
or prod one can get a _few_ local variables (they are truly local and not
computed more than once) when using them together with a suitable final
value for the iteration.
Thorsten
Post a reply to this message
|
![](/i/fill.gif) |