Voir : 
la version texte avec indentation

Tétraèdre de Sierpinski




Tracé des différents itérés


Voir en grand format

Voir en grand format

Voir en grand format

Voir en grand format

Voir en grand format

Voir en grand format





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.





// Tétraèdre de Sierpinski

#include "colors.inc"
#include "sable.inc"

light_source { <6,10,-8> color rgb <0.95,0.95,1>*1.2 }
light_source { <-10,6,6> color rgb <1,0,1>*0.6 }
light_source { <-10,4,20> color rgb <1,0,1>*0.6 }
background { SkyBlue*1.2 }

camera { location <2,1.5,-7>
look_at <2.2,0.45,1>
}


#macro vmilieu(a,b)
<(a.x+b.x)/2, (a.y+b.y)/2, (a.z+b.z)/2 >
#end

#macro tetraedre (a,b,c,d)
union {
triangle { a,b,c}
triangle { a,b,d}
triangle { d,b,c}
triangle { a,d,c}
}
#end

/*
// variante de tétraedre (supprimer le pigment dans l'object final
#macro tetraedre (a,b,c,d)
union {
triangle { a,b,c pigment { Red*1.7 }}
triangle { a,b,d pigment { Green }}
triangle { d,b,c texture { sable2 }}
triangle { a,d,c pigment {White } }
}
#end
*/

#macro sierpinski(a,b,c,d,n)
#if (n=0) tetraedre(a,b,c,d)
#else
sierpinski(a,vmilieu(a,b),vmilieu(a,c),vmilieu(a,d),n-1)
sierpinski(vmilieu(a,b),b,vmilieu(b,c),vmilieu(b,d),n-1)
sierpinski(vmilieu(a,c),c,vmilieu(c,b),vmilieu(c,d),n-1)
sierpinski(vmilieu(a,d),vmilieu(d,b),vmilieu(d,c),d,n-1)
#end
#end

// n est le nombre d'itérations
#declare n=2;


union{ sierpinski (<0,0,0>,<4,0,0>,<2,3.464,0>,<2,1.155,3>,n)
pigment {
gradient <0,1,-0.38>
color_map {
[ 0.1 color red 1.0 green 1.0 blue 1]
[ 0.2 color red 1.0 green 1.0 blue 0]
[ 0.3 color red 1 green 0.8 blue 0.]
[ 0.5 color red 0.8 green 0.6 blue 0 filter 0.5]
} // color_map
scale 0.2/n}

finish {ambient 0.55 diffuse 0.7 specular 0.6 reflection 0.1 roughness 0.01}
rotate <0,75,-20>
scale <1.5,1,1>

}
Début