POV-Ray : Newsgroups : povray.general : Recursion in POV : Re: Recursion in POV Server Time
31 Jul 2024 12:16:05 EDT (-0400)
  Re: Recursion in POV  
From: Bruno Cabasson
Date: 16 Mar 2007 05:45:01
Message: <web.45fa7444581ce19bf5fba6ef0@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> I was studying, the other day, and was struck by a sudden impulse.  Can POV,
> I wondered, handle recursion?  So I wrote the following simple scene:
>
> /*
>  Persistence of Vision Ray Tracer Scene Description File
>  File: Recursion.pov
>  Vers: 3.6
>  Desc: A simple recursive macro
>  Date: 03/14/07
>  Auth: Anthony D. Baye
> */
>
> #include "kolors.inc"
> #include "glass.inc"
> #include "stones.inc"
> #include "metals.inc"
>
> #declare ft = 12 ;
>
> #default { pigment { White } finish { ambient 0.3 diffuse 0.5 } }
>
> camera {
>     location <2.0, 3.0, -5.0>
>     look_at 0.0
>     }
>
> light_source { <15.0, 35.0, -75.0> color rgb 1 }
>
> #macro String_Of_Beads(n)
>
> #if(n >= 0)
>     String_Of_Beads(n-1)
> #end
>
> #local move = (0.25+(0.375*n));
>
>     sphere { <cos(radians(9*n)), sin(radians(9*n)), move>, 0.125
>         texture { T_Stone28 }
>         finish { reflection { 0.05, 0.1 fresnel on } ambient 0.3 diffuse 0.5
>             conserve_energy }
>             }
>     cylinder { <cos(radians(9*n)), sin(radians(9*n)), move>
>         <cos(radians(9*(n+1))), sin(radians(9*(n+1))), (0.25+(0.375*(n+1)))>
>         0.015625 texture { T_Silver_5A }}
>
> #end
>
> String_Of_Beads(96)
>
>     It actually works, but with any values higher than 96, the parse fails,
> and gives the message: "Too many nested symbol tables"  whatever that
> means. (I'm not familiar with the source code.)
>
>     I was wondering, however, is this an inherent limitation, or an imposed
> limitation?  And might it be possible to adapt the parser to allow advanced
> recursion?
>
> Just some thoughts.
>
> Regards,
>
> ADB

I don't see the interst of recursion in that particular case. A loop would
have made the same. Recursion depth of at least 96 is enough for whatever I
could think of. If this internal limitation is not enough for what you want,
you should change the structure of your code or your approach. But it is
often very difficult to code what you have in mind, whatever your skill and
experience are (I have none of them, lol)!!!

    Bruno


Post a reply to this message

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