Voir : la version texte avec indentation
Prismes de Sierpinski
Tracé des différents itérés
La vision en relief permet de bien mieux appréhender ces surfaces complexes dans l'espace.
Ainsi, pour visualiser ces surfaces en relief ( images stéréoscopiques ), aller à cette page.
// Cube et tétraèdre de Sierpinski
#include "colors.inc"
#include "sable.inc"
light_source { <6,15,-8> color rgb <0.95,0.95,1> }
light_source { <-6,10,-6> color rgb <1,1,1> }
light_source { <-1.,1.6,-0.2>*10 color rgb <1,0.8,0>*0.4 }
background { SkyBlue*1.2 }
camera {orthographic location <1.5,3,-0.35>*0.5
look_at <1.2,0.8,1.6>
}
plane{ z, 4.5
pigment { SkyBlue }
finish {ambient 0.65 diffuse 0.3 roughness 0.0001 }
rotate y*15
}
plane{ y,0
texture { sable2 scale 0.2}
finish {ambient 0.8 diffuse 0.2 roughness 0.0001 }
}
# declare rap=1/3;
//------------------------ le cube ---------------------
#macro sierpinski(a,b,c,D,n)
#if (n=0) box{,}
#else
#local DL=D*rap;
sierpinski(a,b,c,DL,n-1)
sierpinski(a+D-DL,b,c,DL,n-1)
sierpinski(a,b,c+D-DL,DL,n-1)
sierpinski(a+D-DL,b,c+D-DL,DL,n-1)
sierpinski(a+D-DL,b+D-DL,c+D-DL,DL,n-1)
sierpinski(a,b+D-DL,c+D-DL,DL,n-1)
sierpinski(a,b+D-DL,c,DL,n-1)
sierpinski(a+D-DL,b+D-DL,c,DL,n-1)
sierpinski(a+DL,b,c,DL,n-1)
sierpinski(a+DL,b+2*DL,c,DL,n-1)
sierpinski(a+DL,b,c+2*DL,DL,n-1)
sierpinski(a+DL,b+2*DL,c+2*DL,DL,n-1)
sierpinski(a,b+DL,c,DL,n-1)
sierpinski(a+2*DL,b+DL,c,DL,n-1)
sierpinski(a,b+DL,c+2*DL,DL,n-1)
sierpinski(a+2*DL,b+DL,c+2*DL,DL,n-1)
sierpinski(a,b,c+DL,DL,n-1)
sierpinski(a+2*DL,b,c+DL,DL,n-1)
sierpinski(a,b+2*DL,c+DL,DL,n-1)
sierpinski(a+2*DL,b+2*DL,c+DL,DL,n-1)/* */
#end
#end
//-------------------- le prisme ---------------------
#macro sierprisme(x1,y1,x2,y2,x3,y3,base1,haut,n)
#if (n=0) prism { linear_spline
base1, base1+haut, 4
,,,}
#else
#local h=haut*rap;
sierprisme(x1,y1,x1+(x2-x1)*rap,y1+(y2-y1)*rap,x1+(x3-x1)*rap,y1+(y3-y1)*rap,base1,h,n-1)
sierprisme(x2+(x1-x2)*rap,y2+(y1-y2)*rap,x2,y2,x2+(x3-x2)*rap,y2+(y3-y2)*rap,base1,h,n-1)
sierprisme(x3+(x1-x3)*rap,y3+(y1-y3)*rap,x3+(x2-x3)*rap,y3+(y2-y3)*rap,x3,y3,base1,h,n-1)
sierprisme(x1+(x3-x1)*rap,y1+(y2-y1)*rap, x3+(x2-x3)*2*rap,y3+(y2-y3)*2*rap, x3+(x2-x3)*rap,y3+(y2-y3)*rap, base1,h,n-1)
sierprisme(x1+(x2-x1)*rap,y1+(y2-y1)*rap,x1+(x2-x1)*2*rap,y1+(y2-y1)*2*rap,x1+(x3-x1)*rap,y1+(y2-y1)*rap, base1,h,n-1)
sierprisme( x1+(x3-x1)*rap,y1+(y3-y1)*rap, x1+(x3-x1)*rap,y1+(y2-y1)*rap,x1+(x3-x1)*2*rap,y1+(y3-y1)*2*rap,base1,h,n-1)
sierprisme(x1,y1,x1+(x2-x1)*rap,y1+(y2-y1)*rap,x1+(x3-x1)*rap,y1+(y3-y1)*rap,base1+h,h,n-1)
sierprisme(x2+(x1-x2)*rap,y2+(y1-y2)*rap,x2,y2,x2+(x3-x2)*rap,y2+(y3-y2)*rap,base1+h,h,n-1)
sierprisme(x3+(x1-x3)*rap,y3+(y1-y3)*rap,x3+(x2-x3)*rap,y3+(y2-y3)*rap,x3,y3,base1+h,h,n-1)
sierprisme(x1,y1,x1+(x2-x1)*rap,y1+(y2-y1)*rap,x1+(x3-x1)*rap,y1+(y3-y1)*rap,base1+2*h,h,n-1)
sierprisme(x2+(x1-x2)*rap,y2+(y1-y2)*rap,x2,y2,x2+(x3-x2)*rap,y2+(y3-y2)*rap,base1+2*h,h,n-1)
sierprisme(x3+(x1-x3)*rap,y3+(y1-y3)*rap,x3+(x2-x3)*rap,y3+(y2-y3)*rap,x3,y3,base1+2*h,h,n-1)
sierprisme(x1+(x3-x1)*rap,y1+(y2-y1)*rap, x3+(x2-x3)*2*rap,y3+(y2-y3)*2*rap, x3+(x2-x3)*rap,y3+(y2-y3)*rap, base1+2*h,h,n-1)
sierprisme(x1+(x2-x1)*rap,y1+(y2-y1)*rap,x1+(x2-x1)*2*rap,y1+(y2-y1)*2*rap,x1+(x3-x1)*rap,y1+(y2-y1)*rap, base1+2*h,h,n-1)
sierprisme( x1+(x3-x1)*rap,y1+(y3-y1)*rap, x1+(x3-x1)*rap,y1+(y2-y1)*rap,x1+(x3-x1)*2*rap,y1+(y3-y1)*2*rap,base1+2*h,h,n-1)
#end
#end
//-------------------------------------------------------
// n est le nombre d'itérations
#declare n=2;
union { // union 1
union{ // union 2
sierpinski (1.3,0,0,1,n)
texture{
pigment {
dents
color_map {
[ 0.1 rgb <0.95,1,0.95>*0.95]
[ 0.1 rgb <0.7,1,0.6>]
[ 0.4 rgb <0.3,0.8,0.5> ]
[ 0.5 rgb <0.2,0.7,0.7>]
} // color_map
scale 0.002
} //fin pigment
} // fin texture
finish {ambient 0.2 diffuse 0.5 specular 0.4 roughness 0.1 }
} // fin union 2
union{ // union 3
sierprisme (0,0,0,1,1,0,0,1,n)
pigment { brick
color Gray*1.2,
color Red
brick_size <2,0.795,1>
mortar 0.2
scale 0.02
}
finish {ambient 0.2 diffuse 0.7 specular 0.4 roughness 0.1 }
} // fin union 3
rotate <0,205,0>
translate <2.6,0,2>
} // fin union 1
Début