POV-Ray : Newsgroups : povray.advanced-users : function optimization question : Re: function optimization question Server Time
29 Jul 2024 20:21:32 EDT (-0400)
  Re: function optimization question  
From: Ron Parker
Date: 19 Mar 2002 10:30:40
Message: <slrna9emd1.ei2.ron.parker@fwi.com>

> On Sat, 16 Mar 2002 16:02:52 +0100, "Jan Walzer" <jan### [at] lzernet> wrote:
>> All we miss then yet is only iteration/recursion inside of these functions, and
they're turing-complete ...
> 
> Personally I think that internally functions are ready for recursions :-)
> I've got message "Possible infinite recursive function call." some time.
> I've also got message like "Reached maximum number of
> recursion in functions". In both cases messages were produced as a result of
> bug as I reported in povray.beta-test but the fact they are builded in POV-Ray
> lead me to conclusion that recursion is a part of design :-)

Loops, too.  They're just not part of the syntax.  The 3.5 beta has some
debugging features built in, though, so you can actually use them.  For 
example, here's a simple iterative factorial function:

#declare Fact=function(x) {"fact.out","fact.func" };

#debug concat(str(Fact(0),3,3), "\n")
#debug concat(str(Fact(1),3,3), "\n")
#debug concat(str(Fact(2),3,3), "\n")
#debug concat(str(Fact(3),3,3), "\n")
#debug concat(str(Fact(4),3,3), "\n")

and here are the contents of the file "fact.func":

grow    2
load    SP(0),r2
loadi   1,r0
cmpi    0,r2
ble     8
mul     r2,r0
subi    1, r2
jmp     3
rts

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}


Post a reply to this message

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