|
![](/i/fill.gif) |
I've managed to write a macro to generate a a sierpinski polygon of n sides, but
I'm having a few problems. First, I would expect the 4-sided polygon
(sierpinski square) to look like a Mengher sponge, but it doesn't.
This is not my main problem, however.
What I'm trying to do is something like this:
http://www.fractalsciencekit.com/gallery/orbital/f1058.jpg
which the site says is a sierpinski n-gon, but I can't figure out how they did
it, and they aren't really saying except that it was done with their software.
If anyone can help me, I'd appreciate it.
Regards,
A.D.B.
Code Listing:
#include "kolors.inc"
#include "math.inc"
#include "functions.inc"
light_source { <0.0, 0.0, -20.0> 1.0 }
camera {
perspective
location <0.0, -10.0, -1.5>
up y
right (image_width/image_height)*x
look_at <0.0, -10.0, 0.0>
}
#default { pigment { White } finish { ambient 0.3 diffuse 0.6 } }
#macro nGon(n, rad)
prism {
-0.0625, 0.0625, 2*n+1
#local i = 0;
#while(i <= 2*n)
#if(i <= n)
rad*<sind( i * (360/n) ), cosd( i * (360/n) )>
#else
(rad-0.015625) * <sind( i * (360/n) ), cosd( i * (360/n) )>
#end
#local i = i + 1;
#end
pigment { function { r(x,y,z,1) } color_map { [0 rgb 0] [1 rgb 1]
} }
rotate -90.0*x
}
#end
#macro sierpinski(n, rad, E, T)
#ifndef(fn)
#local fn = function(N){1/(2*(1+sum(k,1,N/4,cos(2*pi*k/N))))}
#end
object {
union {
union {
#if(rad >= E)
#local i = 0;
#while(i <= n)
#local T1 = (1 - fn(n) ) * rad * <sin(2*pi*(i)/n), cos(2*pi*(i)/n), 0>;
sierpinski(n, rad*fn(n), E transform { translate T1 })
#local i = i + 1;
#end
#end
}
//nGon(n, r)
sphere { 0.0, 0.00390625 }
}
transform { T }
}
#end
sierpinski(8, 10, 1/64, transform { translate 0*x })
Post a reply to this message
|
![](/i/fill.gif) |