Icosaèdre tronqué
Posté : sam. 14 avr. 2012, 09:40
Animation d'un Icosaèdre tronqué, demandée par XavTex :
Je me suis contenté d'ajouter les lignes utiles pour transformer l'image suivante en une animation gif.
Je me suis contenté d'ajouter les lignes utiles pour transformer l'image suivante en une animation gif.
Code : Tout sélectionner
//settings.outformat="gif";
settings.prc=false;
import animate;
import graph3;
defaultrender.merge=true;
size(300);
animation A;
real c=(1+sqrt(5))/2;
triple[] z={(c,1,0),(-c,1,0),(-c,-1,0),(c,-1,0)};
triple[] x={(0,c,1),(0,-c,1),(0,-c,-1),(0,c,-1)};
triple[] y={(1,0,c),(1,0,-c),(-1,0,-c),(-1,0,c)};
triple[][] Q={
{(c,1,0),(1,0,-c),(0,c,-1),(0,c,1),(1,0,c),(c,-1,0)},
{(-c,1,0),(0,c,1),(0,c,-1),(-1,0,-c),(-c,-1,0),(-1,0,c)},
{(-c,-1,0),(-c,1,0),(-1,0,-c),(0,-c,-1),(0,-c,1),(-1,0,c)},
{(c,-1,0),(c,1,0),(1,0,c),(0,-c,1),(0,-c,-1),(1,0,-c)},
{(0,c,1),(0,c,-1),(-c,1,0),(-1,0,c),(1,0,c),(c,1,0)},
{(0,-c,1),(0,-c,-1),(-c,-1,0),(-1,0,c),(1,0,c),(c,-1,0)},
{(0,-c,-1),(0,-c,1),(c,-1,0),(1,0,-c),(-1,0,-c),(-c,-1,0)},
{(0,c,-1),(0,c,1),(c,1,0),(1,0,-c),(-1,0,-c),(-c,1,0)},
{(1,0,c),(-1,0,c),(0,-c,1),(c,-1,0),(c,1,0),(0,c,1)},
{(1,0,-c),(-1,0,-c),(0,-c,-1),(c,-1,0),(c,1,0),(0,c,-1)},
{(-1,0,-c),(1,0,-c),(0,c,-1),(-c,1,0),(-c,-1,0),(0,-c,-1)},
{(-1,0,c),(1,0,c),(0,c,1),(-c,1,0),(-c,-1,0),(0,-c,1)}
};
real R=abs(interp(Q[0][0],Q[0][1],1/3));
triple[][] P;
for(int i=0; i < Q.length; ++i) {
P[i]=new triple[] ;
for(int j=0; j < Q[i].length; ++j) {
P[i][j]=Q[i][j]/R;
}
}
for (int k=0; k<180; k+=5) {
transform3 T=rotate(-degrees(2pi*k/360),Z);
for(int i=0; i < P.length; ++i) {
for(int j=1; j < P[i].length; ++j) {
triple C=P[i][0];
triple A=P[i][j];
triple B=P[i][j % 5+1];
triple[] sixout=new
triple[] {interp(C,A,1/3),interp(C,A,2/3),interp(A,B,1/3),interp(A,B,2/3),
interp(B,C,1/3),interp(B,C,2/3)};
triple M=(sum(sixout))/6;
triple[] sixin=sequence(new triple(int k) {
return interp(sixout[k],M,0.1);
},6);
draw(T*surface(reverse(operator--(...sixout)--cycle)^^
operator--(...sixin)--cycle,planar=true),magenta);
}
}
for(int i=0; i < P.length; ++i) {
triple[] fiveout=sequence(new triple(int k) {
return interp(P[i][0],P[i][k+1],1/3);
},5);
triple M=(sum(fiveout))/5;
triple[] fivein=sequence(new triple(int k) {
return interp(fiveout[k],M,0.1);
},5);
draw(T*surface(reverse(operator--(...fiveout)--cycle)^^
operator--(...fivein)--cycle,planar=true),cyan);
}
draw(unitsphere,nullpen);
A.add();
erase();
}
A.movie(delay=1000);