POV-Ray : Newsgroups : povray.general : Recursion in POV : Recursion in POV Server Time
31 Jul 2024 12:22:55 EDT (-0400)
  Recursion in POV  
From: Anthony D  Baye
Date: 15 Mar 2007 13:35:01
Message: <web.45f9905abe4748272de2099c0@news.povray.org>
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


Post a reply to this message

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