|
 |
ian wrote:
> Hello,
>
> Here is a little pyramid I've made with the help of a macro from the
> internet. It took about one day to parse and render.
>
> I use an iteration 8 pyramid sponge 25 times to build another pyramid, which
> I use 25 times to make another, and I do this once again resulting in 15,625
> of those iteration 8 pyramids using my 3 loops.
>
> The way I do it creates about 8 superfluous pyramids per loop (which were
> uncounted in the 25 figure), so about 512 useless RAM sucking pyramids for
> the whole thing (8 in loop1 8times in loop2 8times in loop3).
>
> I'd like to get rid of them. Any help is appreciated.
> ...
The idea of putting the two reflecting spheres inside
this fractal like pyramid is nice
I would love to have a closer look at the reflections
in them.
Then about your superfluous pyramids problem:
I think your macro is not the problem. (For me it
does not seem to generate unnecessary triangles.)
So therefore I think the problem must lie within the
rest of your code.
You could try to simplify the rest of your code.
(E.g. like I did with your macro in the code below).
Maybe it then will be easier for you to spot the "bug".
I think one error is that your loops are putting multiple
copies of the last assembled pyramid at some of the
locations they are translated to (And therefore I
suspect that the number of unnecessary pyramid
copies are far more than 512 !)
And last:
What does "untersheisse" mean. Is it german ?
Tor Olav
--
mailto:tor### [at] hotmail com
http://www.crosswinds.net/~tok/tokrays.html
Btw.:
It seems for me that most of the rest of your code
is "doing by hand" what your macro could do for you.
Wouldn't a call like this do roughly the same job as
most of your other lines does ?
#declare Corn =
mesh {
pyramid(SZ*4*y, SZ*4, 0, 8 + 2 + 2 + 2)
pigment { color 0.6*White }
finish { phong 0.2 }
translate 3*(SZ/2 + 5 + 1.25)*<1, 0, 1>
}
Here's my suggestion for the macro:
#macro pyramid(p0, size, rec, maxrec)
#local SS = size*<1, 1, 1>;
#local p1 = p0 - SS/<-2, 1, -2>;
#local p2 = p0 - SS/< 2, 1, -2>;
#local p3 = p0 - SS/< 2, 1, 2>;
#local p4 = p0 - SS/<-2, 1, 2>;
#if (rec >= maxrec)
triangle { p0, p1, p2 }
triangle { p0, p2, p3 }
triangle { p0, p3, p4 }
triangle { p0, p4, p1 }
triangle { p1, p2, p3 }
triangle { p3, p4, p1 }
#else
pyramid( p0 , size/2, rec + 1, maxrec)
pyramid((p0 + p1)/2, size/2, rec + 1, maxrec)
pyramid((p0 + p2)/2, size/2, rec + 1, maxrec)
pyramid((p0 + p3)/2, size/2, rec + 1, maxrec)
pyramid((p0 + p4)/2, size/2, rec + 1, maxrec)
#end // if
#end // macro pyramid
And here's my suggestion of how to start simplifying your
code (But only if you're interested :)
I'll use this line as an example:
translate <(-Y*(SZ/2))+(SZ*3),Y*SZ,(-Y*(SZ/2))+(SZ*3)>
First make it more friendly to the eye. Put in some spaces
after commas and around - and + to indicate that they are
"weaker" than * and /
translate <(-Y*(SZ/2)) + (SZ*3), Y*SZ, (-Y*(SZ/2)) + (SZ*3)>
Then remove all unnecessary parenthesis
(I.e. all in this case)
translate <-Y*SZ/2 + SZ*3, Y*SZ, -Y*SZ/2 + SZ*3>
Then find the common multiplier for each part in each
component of the vector and put this outside some
parenthesis:
translate <SZ*(-Y/2 + 3), SZ*Y, SZ*(-Y/2 +3)>
Now you see that each component of the vector also has SZ
as a common multiplier, so then you can put this outside
the vector and remove the parenthesis again:
translate SZ*<-Y/2 + 3, Y, -Y/2 +3>
Then maybe you see that the vector now can be
written as a sum of two vectors.
I.e.: <-Y/2 + 3, Y, -Y/2 +3> = <-Y/2, Y, -Y/2> + <3, 0, 3>
If so then you can write the statement like this:
translate SZ*(<-Y/2, Y, -Y/2> + <3, 0, 3>)
Again you can see that there is a common multiplier for
each component in the first vector and also for the last
vector. So put these multipliers outside the vectors.
Then we get:
translate SZ*(Y/2*<-1, 2, -1> + 3*<1, 0, 1>)
Then I would say that you're finished.
Or maybe you prefer this ?
translate SZ*(Y*<-0.5, 1.0, -0.5> + <3, 0, 3>)
Then compare the readability of that to the readability
of the statement as it was:
translate <(-Y*(SZ/2))+(SZ*3),Y*SZ,(-Y*(SZ/2))+(SZ*3)>
Post a reply to this message
|
 |