POV-Ray : Newsgroups : povray.general : Another recursive problem: Server Time
2 Aug 2024 12:18:01 EDT (-0400)
  Another recursive problem: (Message 1 to 2 of 2)  
From: Jay D  Patteson
Subject: Another recursive problem:
Date: 11 Nov 2004 19:40:00
Message: <web.419405c85b7bf2746f3457240@news.povray.org>
I'm trying to do a seirpenski (sp?) gasket in cube form.

However, when I set the initial call to the function at more than 1 (+1)
iterations, it just gives me a solid cube.  I don't get it.  can anyone see
what I did wrong?  It worked beautifully fine before I changed the
iteration call from 20 static calls to the same function to a 3x3x3 loop
(testing for the 7 values which don't need to be used) to knock out all the
20 blocks around each center.

here is my code:


#version 3.5;
#include "colors.inc"
global_settings {
  assumed_gamma 1.0
}

camera {
  location  <6.0, 9.0, 3.0>

  look_at   <0.0, 0.0,  0.0>
}
sky_sphere {
  pigment {
    gradient z
    color_map {
      [0 red .1]
      [.5 blue .1]
      [1 red .1]
    }
 scale <.01,.01,.01>
  }
}
light_source {
<6.0, 9.0, 3.0>
  color rgb 1
}


#macro killpart()
box {<-3.01,-1,-1><3.01,1,1>}
box {<-1,-3.01,-1><1,3.01,1>}
box {<-1,-1,-3.01><1,1,3.01>}
#end

#macro killall(iteration)

killpart()

#if (iteration>0)
union{


#declare loopx=-1;
#while (loopx<=1)
#declare loopy=-1;
#while (loopy<=1)
#declare loopz=-1;
#while (loopz<=1)


#if ((loopx=0 & loopy=0) | (loopy=0 & loopz=0) | (loopz=0 & loopx=0))
#else
union {
killall(iteration-1)
scale 1/3
translate<2*loopx,2*loopy,2*loopz>
}
#end

#declare loopz=loopz+1;
#end
#declare loopy=loopy+1;
#end
#declare loopx=loopx+1;
#end


}
#end

#end

difference {
box {-3,3}

union{
killall(1)   //<----  here is where, if I set the initial call to more than
just 1, it just gives me a solid cube.
}
pigment {green 1}
}


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Another recursive problem:
Date: 11 Nov 2004 21:21:26
Message: <41941e26$1@news.povray.org>
Jay D. Patteson wrote:
> I'm trying to do a seirpenski (sp?) gasket in cube form.
> 
> However, when I set the initial call to the function at more than 1 (+1)
> iterations, it just gives me a solid cube.  I don't get it.  can anyone see
> what I did wrong?  It worked beautifully fine before I changed the
> iteration call from 20 static calls to the same function to a 3x3x3 loop
> (testing for the 7 values which don't need to be used) to knock out all the
> 20 blocks around each center.


> here is my code:
...
> #macro killall(iteration)
> 
> killpart()
> 
> #if (iteration>0)
> union{
> 
> 
> #declare loopx=-1;
...

You should use #local instead of #declare for local
variables inside macors.

A little indentation would be nice for increased
readability of your code.

Here's some useful information to help you increase
the rendering speed of object with a lot of holes:

   http://www.econym.demon.co.uk/holetut/

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

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