5 : Triangle de siepinski

#include "colors.inc"
//Place the camera
camera {
  sky <0,0,1>          //Don'tchange this
  direction <-1,0,0>   //Don'tchange this 
  right <-4/3,0,0>     //Don'tchange this
  location  <0,0,10>
  look_at   <0,0,0>
  angle 16
}
global_settings { ambient_light White }
light_source {<0,0,10>
  color White
}
background { color White }
//Define the coordinates of the three
vertices of a triangle
//Notice that the angle must be given in radians
#declare p1 =
<cos(90*pi/180),sin(90*pi/180),0>;
#declare p2 =
<cos(210*pi/180),sin(210*pi/180),0>;
#declare p3 =
<cos(330*pi/180),sin(330*pi/180),0>;
//Define the triangle
#declare mytriangle = object{polygon {4, p1, p2, p3, p1} texture {pigment{Red}} };
#declare counter=1;
#declare n=3;
//Make a loop in which the triangle is shrunk and translated toward each corner
#while(counter < n)
  #declare mytriangle=union{
    object{mytriangle scale .5 translate .5*p1}
    object{mytriangle scale .5 translate .5*p2}
  object{mytriangle scale .5 translate .5*p3}
}
  #declare counter=counter+1;
#end
//Display the triangle
mytriangle

6: koch

#incl ude "colors.inc"
//Place de la camera
camera {
sky<0,0,1>        
direction <-1,0,0>  
right<-4/3,0,0>    
location  <0,0,10>
look_at   <0,0,0>
angle 16
}
light_source {<0,0,10>
color White
}
background { color White }
#declare
r=0.005;                          
//coordonnées du triangle

#declare p2 = <cos(90*pi/180),sin(90*pi/180),0>;

#declare p1 = <cos(210*pi/180),sin(210*pi/180),0>;

#declare p3 = <cos(330*pi/180),sin(330*pi/180),0>;

#macro koch(a,b,n)
# local c=vrotate((b-a)/3,<0,0,60>);
#if (n>0)
union{
koch(a,a+(b-a)/3,n-1) 
koch(a+(b-a)/3,a+(b-a)/3+c,n-1)
koch( a+(b-a)/3+c,a+2*(b-a)/3,n-1)
koch(a+2*(b-a)/3,b,n-1)
}
#else
union{
cylinder{ a,a+(b-a)/3,r}
cylinder{a+(b-a)/3,a+(b-a)/3+c,r}
cylinder{ a+(b-a)/3+c,a+2*(b-a)/3,r}
cylinder{ a+2*(b-a)/3,b,r}
pigment {color Red}
}
#end
#end
koch(p1,p2,clock)
koch(p2,p3,clock)
koch(p3,p1,clock) 
C'est un programme récursif.
7: Fougère de Barnsley
#include "colors.inc"
//Place de la camera
camera {
  sky <0,0,1>          //Don't change this
  direction <-1,0,0>   //Don't change this 
  right <-4/3,0,0>     //Don't change this
  location  <0,0,10>
  look_at   <0,1,0>
  angle 20
}
global_settings { ambient_light White }
light_source {<0,0,10>
color White
}
background { color White }
 #declare r=0.005;                         
#declare p1 = <0,1,0>;
#declare p2=<0,0,0>;
 #macro fou(a,b,n)
 #if (n>0)
  union
  {
 fou(0.3*(<0,0.8,0>+vrotate(a, <0,0,50>)),0.3*(<0,0.8,0>+vrotate(b, <0,0,50>))  ,n-1)
  fou(0.3*(<0,0.2,0>+vrotate(a, <0,0,-50>)),0.3*(<0,0.2,0>+vrotate(b, <0,0,-50>))  ,n-1)
 fou(0.8*(<0,0.6,0>+vrotate(a,<0,0,2>)),0.8*(<0,0.6,0>+vrotate(b,<0,0,2>)),n-1)
fou(a,b,n-1)
}
#else
cylinder{a,b,r pigment{color Green} }
#end
#end 
fou( p2,p1,7) 

8: Arbre en 2 dimensions

#include "colors.inc"
//Place the camera
camera {
  sky <0,0,1>          //Don't change this
  direction <-1,0,0>   //Don't change this 
  right <-4/3,0,0>     //Don't change this
  location  <0,0,10>
  look_at   <0,1,0>
  angle 30
}
global_settings { ambient_light White }
light_source {  <0,0,10>
  color White
}
background { color White }
 #declare r=0.01;                         
#declare p1 = <0,0,0>;
#declare p2 = <0,1,0>;
 #macro arb(a,b,n,epais)
#if (n>0)
union{
arb(b, b+0.6*vrotate((b-a),<0,0,30>),n-1,epais*.6) 
arb(b, b+0.6*vrotate((b-a),<0,0,-30>),n-1,epais*0.6)
arb(a,b,n-1,epais)
}
#else
cone{a,epais,b,epais*3/5 pigment{color Green}
 }
#end
#end
arb(p1,p2,10,0.1)
9: arbre en dimensions 3

#include "colors.inc"

light_source { <6,15,-7> color rgb <0.95,0.95,1> shadowless}

light_source { <-6,15,-6> color rgb <1,1,1> }

//light_source { <-1.,1.6,-0.2>*20 color rgb <1,0.8,0>*0.4 shadowless}

background { SkyBlue*1.2 }

camera {orthographic location <0,3,-5>

look_at <0,0,3>

angle 30

}

plane{ y,-1 texture {pigment { marble color_map {[0.2 color White*0.999 ][0.5 color White ]}

turbulence 0.5 scale <1,5,1>

}

normal { granite 0.7 accuracy 0.0001 turbulence 0.2 scale 8

}

finish {ambient 0.5 diffuse 0.7}

} //texture

} //plane

 

//------------------------ arbre 3d ---------------------

# declare r=0.4;

 #macro arbre3d(n)

#if (n=1) cone{<0,0,0>,r/6,<0,1,0>,r/7}

#else

union{ union{

object{ arbre3d(n-1) rotate <30,0,0> scale 0.7}

object{ arbre3d(n-1) rotate <-50,0,-30> scale 0.65}

object{ arbre3d(n-1) rotate <10,0,40> scale 0.65}

translate 1*y

rotate 360*0.6*y }

 arbre3d(n-1)

}

#end

#end

object{ arbre3d(9)

texture{ pigment {rgb <0.6,0.55,0.5>}}

}

10 : sierpinski en dimensions 3
#include "colors.inc"
global_settings
{ assumed_gamma 1.0}
//Placede la camera
camera {
  sky <0,0,1>        
  direction <-1,0,0>    
  right <-4/3,0,0>    
  location  <5,6,5>
  look_at   <0,0,0>
  angle 40
}
background { color White }
light_source
{  0*x
    color red 1.0  green 1.0  blue 1.0
    shadowless
    translate <-50, -150, 100>
}  
//coordonnées du tétraèdre
#declare b=1 ;
#declare p1 = <b,b,b>;
#declare p2 = <b,-b,-b>;
#declare p3 = <-b,-b,b>;
#declare p4=<-b,b,-b>; 
#declare r=0.03;
//le tétraèdre
#declare tetra = union{triangle {p1,p2,p3  pigment {color Green
transmit 0.6}} triangle {p1,p2,p4 pigment {color Green transmit 0.6}}
triangle {p1,p3,p4 pigment {color Green transmit 0.6}}
 triangle {p2,p3,p4 pigment {color Green transmit
0.6}}   cylinder{p1,p2,r pigment{color Blue} }
cylinder{p1,p3,r pigment{color Blue} } cylinder{p1,p4,r pigment{color
Blue} }cylinder{p2,p3,r pigment{color Blue} }
 cylinder{p2,p4,r pigment{color Blue} }cylinder{p4,p3,r pigment{color Blue}  } }
#declare
n=0;                                                                                            
//à chaque itération la figure est divisée par 2 et translatée vers chaque sommet
#while(n<3)
  #declare tetra=union{
    object{tetra scale .5 translate .5*p1}
    object{tetra scale .5 translate .5*p2}
    object{tetra scale .5 translate .5*p3}
     object{tetra scale .5 translate .5*p4}
}
  #declare n=n+1;
#end
tetra
sphere{<0,0,0>,r pigment{color Black}}
11. Koch en 3 dimensions

#include "colors.inc"
global_settings
{
  assumed_gamma 1.0
}
//Place the camera
camera {
  sky <0,0,1>          //Don't change this
  direction <-1,0,0>   //Don't change this 
  right <-4/3,0,0>     //Don't change this
  location  <-4,-8,8>
  look_at   <0,0,0>
  angle 30
}
background { color White }
light_source { <100, 100, -10> color White }
light_source { <-100, 100, 10>*0.1 color White }
 light_source { <100,-100, 100>*0.1 color White }
//coordonnées du tétraèdre
#declare b=1 ;
#declare e1 = <b,b,b>;
#declare e2 = <b,-b,-b>;
#declare e3 = <-b,-b,b>;
#declare e4=<-b,b,-b>; 
#declare r=0.02;
#macro tetra(p1,p2,p3,p4)
   union{triangle {p1,p2,p3  pigment{color Yellow}}
triangle {p1,p2,p4  pigment{color Red}}
 triangle {p1,p3,p4pigment{color Green}}
 triangle {p2,p3,p4 pigment {color Cyan }} 
   }
 #end
#macro koch(p1,p2,p3,p4,n)
#if (n>0)
union{
  koch(p1,p2,p3,p4,n-1)
  koch(-p1/2+(p2+p3+p4)/2,(p2+p3)/2,(p3+p4)/2,(p4+p2)/2,n-1)
  koch(-p2/2+(p1+p3+p4)/2,(p1+p3)/2,(p3+p4)/2,(p4+p1)/2,n-1)
  koch(-p3/2+(p1+p2+p4)/2,(p1+p2)/2,(p2+p4)/2,(p4+p1)/2,n-1)
  koch(-p4/2+(p1+p2+p3)/2,(p1+p2)/2,(p2+p3)/2,(p3+p1)/2,n-1)
}
#else
tetra(p1,p2,p3,p4)
#end
#end  
koch(e1,e2,e3,e4,5)







Retour