POV-Ray : Newsgroups : povray.general : Recursion re...uh..iterated? : Re: Recursion re...uh..iterated? Server Time
31 Jul 2024 10:20:52 EDT (-0400)
  Re: Recursion re...uh..iterated?  
From: Paul Fuller
Date: 2 Apr 2007 01:33:21
Message: <461095a1@news.povray.org>
The recursive calls should be in an else clause.

Otherwise they are being called even after the limit is reached and it 
never ends.

Hence the overflow.

Anthony D. Baye wrote:
> The following scene refuses to parse due to an error that POV describes as
> "Too many nested symbol tables."
> It appears to me to be a classic recursion case.  I cannot think of any
> reasonable way it could be done iteratively.
> 
> Those of you that understand what I'm trying to do, try to ignore anything
> that looks odd, I translated the code from LOGO.  That isn't easy.
> 
> /*
>     Persistence of Vision Ray-Tracer Scene Description File.
>     Name: Koch.pov
>     Vers: 3.6
>     Desc: A Koch Curve
>     Date: 033107
>     Auth: Anthony D. Baye
> */
> 
> #include "kolors.inc"
> #include "textures.inc"
> #include "metals.inc"
> 
> light_source { <2.5, 15.0, -7.5> rgb 1 }
> camera {
>     orthographic
>     location 5.0*y
>     look_at 0.0
>     }
> 
> #macro Koch(Len, Lim, cP, cA)
> 
> #if(Len < Lim)
>     #local i = 0;
>     #while(i <= Len)
>         #local fd = <i*sin(radians(cA)), i*cos(radians(cA)), 0.0>;
>         sphere { cP, 0.00390625 translate fd texture { T_Silver_5A } }
>     #local i = i + 0.0078125;
>     #end
> #end
> 
> 
> Koch(
>     Len/3,
>     Lim,
>     <-Len/2, 0.0, 0.0>,
>     0.0
>     )
> Koch(
>     Len/3,
>     Lim,
>     <(-Len/2)+(Len/3), 0.0, 0.0>,
>     cA+60
>     )
> Koch(
>     Len/3,
>     Lim,
>     <(-Len/2)+(Len/3)+((Len/3)*cos(radians(cA)),
>     (Len/3)*sin(radians(cA)), 0.0>,
>     cA-120
>     )
> Koch(
>     Len/3,
>     Lim,
>     <(-Len/2)+(2*Len/3), 0.0, 0.0>,
>     cA+60
>     )
> 
> #end
> 
> Koch(6.0, 1.0, 0.0, 0.0)
> 
> Like I said, I translated it from LOGO, so if it doesn't make the most
> sense, it's because I'm still working on it, which is difficult when I
> can't parse it.
> 
> There probably isn't a way to get it to work in this form with the current
> version of POV, and I'm not as interested in iterative solutions, but If
> anyone has a workaround...  I'm all ears.
> 
> Regards,
> 
> ADB
> 
> 
>


Post a reply to this message

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