POV-Ray : Newsgroups : povray.general : recursion problem : Re: recursion problem Server Time
5 Nov 2024 11:20:23 EST (-0500)
  Re: recursion problem  
From: Lenx
Date: 17 Apr 2003 05:50:21
Message: <3e9e78dd$1@news.povray.org>
thank you all, i got something working yesterday, this is my code:

//------------------macro---------------------
#macro Recurse(currentlevel, currentscale)

object{  box{ <-50,0,-50> <50,10,50> pigment{ rgb 1}}   scale
<1/currentscale,1,1/currentscale>  pigment{ rgb 1 } }

#if (currentlevel<recursionmax)

   union{
      Recurse(currentlevel+1, currentscale*scalemultiplier)
      translate
<-50/(currentscale*scalemultiplier),0,-50/(currentscale*scalemultiplier)>
      translate <50/currentscale,10/currentscale,50/currentscale>
      }
   union{
      Recurse(currentlevel+1, currentscale*scalemultiplier)
      translate
<50/(currentscale*scalemultiplier),0,-50/(currentscale*scalemultiplier)>
      translate <-50/currentscale,10/currentscale,50/currentscale>
      }
   union{
      Recurse(currentlevel+1, currentscale*scalemultiplier)
      translate
<-50/(currentscale*scalemultiplier),0,50/(currentscale*scalemultiplier)>
      translate <50/currentscale,10/currentscale,-50/currentscale>
      }
   union{
      Recurse(currentlevel+1, currentscale*scalemultiplier)
      translate
<50/(currentscale*scalemultiplier),0,50/(currentscale*scalemultiplier)>
      translate <-50/currentscale,10/currentscale,-50/currentscale>
      }

#end
#end

//----------calling the macro----------
#declare scalemultiplier=3;
#declare recursionmax=4;
Recurse(0,1)
//-------------end of code-------------


now i am looking to do something like recursion into recurion (my mind is
getting twisted though)
i hope i can come up with the scene i have in mind soon.

regards, lenx (still breaking his head on the
mouse-has-to-find-cheese-in-a-maze problem in java)


Post a reply to this message

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