POV-Ray : Newsgroups : povray.general : more interesting functions is isosurface : Re: more interesting functions is isosurface Server Time
1 Aug 2024 14:35:37 EDT (-0400)
  Re: more interesting functions is isosurface  
From: Thorsten Froehlich
Date: 11 Sep 2005 08:53:33
Message: <432428D0.4050607@trf.de>
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

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