Code : Tout sélectionner
import three;
picture pic;
unitsize(pic,4mm);
currentprojection=orthographic((13,-12,4),up=Z);
currentlight=nolight;
viewportmargin=(4mm,4mm);
int n=10; // nombre de marches
real a=5, // rapport emmarchement/hauteur d'une marche
r=28/17, // rapport giron/hauteur d'une marche
p=5; // profondeur du palier
path3 contremarches[], marches[], palier, profil;
surface contremarches3[], marches3[];
for(int k=0; k<n; ++k){
contremarches.push((0,r*k,k)--(0,r*k,k+1));
marches.push((0,r*k,k+1)--(0,r*(k+1),k+1));
profil=profil--contremarches[k]--marches[k];
contremarches3.push(extrude(contremarches[k],a*X));
marches3.push(extrude(marches[k],a*X));
draw(pic,contremarches3[k],.8paleblue,1bp+black);
draw(pic,marches3[k],paleblue,1bp+black);
}
palier=(0,r*n,n)--(0,r*n+p,n)--(0,r*n+p,0)--(0,0,0);
draw(pic,extrude(palier,a*X),.8paleblue,1bp+black);
profil=profil--palier--cycle;
draw(pic,surface(profil^^shift(a,0,0)*profil),.8palegray);
projection[][] GMViews={{RightView,FrontView},
{currentprojection,TopView}};
addViews(pic,GMViews);