Sections d’un cube par des plans parallèles

cube2

input geometriesyr16;
input dlf_tex.mp;

u:=1cm;

%----------------------------------- Définition du cadre
path cadre;
numeric xmin,xmax,ymin,ymax;
xmin:=-10u;
xmax:=10u;
ymin:=-7u;
ymax:=7u;

cadre:=(xmin,ymin)--(xmax,ymin)--(xmax,ymax)--(xmin,ymax)--cycle;


%---------------------------------- Définitions générales utilisées
%                                   sur toutes les figures

pickup pencircle scaled 1.2bp;


typerepre:="persp";

color A,B,C,D,E,F,G,H,I,J,K, L,M,N,O,P,Q;

I:=0.2[D,A];
J:=0.3[D,C];
K:=0.6[D,E];

numeric a,b,c,d;
a:=5;
b:=40; %init=30
c:=35;
d:=200;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%0
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i:=0 upto 4:


figureespace(-20u,-20u,20u,20u);
Initialisation(a,b,c,d);

trace Cube(A,B,C,D,E,F,G,H);


color R,S,T,V;
V:=(0,0,i*0.1);
R:=I +V;
S:=J +V;
T:=K +V;



L:=IntersectionPlanDroite(R,S,T,D,A);
M:=IntersectionPlanDroite(R,S,T,D,C);
N:=IntersectionPlanDroite(R,S,T,D,E);

path section;
section=buildcycle(segment(L,M),segment(M,N),segment(N,L));

fillcolor:=1.3orange;
transparence section;


trace chemin(L,M,N,L) dashed evenly withcolor red;

nomme.top(L);
nomme.top(M);
nomme.top(N);


nomme.llft(A);
nomme.bot(B);
nomme.rt(C);
nomme.ulft(D);
nomme.ulft(E);
nomme.lft(F);
nomme.lrt(G);
nomme.urt(H);

draw cadre withcolor black withpen pencircle scaled 2pt;
clip currentpicture to cadre;

finespace;

endfor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%0
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i:=5 upto 14:


figureespace(-20u,-20u,20u,20u);
Initialisation(a,b,c,d);

trace Cube(A,B,C,D,E,F,G,H);


color R,S,T,V;
V:=(0,0,i*0.1);
R:=I +V;
S:=J +V;
T:=K +V;



L:=IntersectionPlanDroite(R,S,T,D,A);
M:=IntersectionPlanDroite(R,S,T,D,C);
N:=IntersectionPlanDroite(R,S,T,E,H);
O:=IntersectionPlanDroite(R,S,T,E,F);


path section;
section=buildcycle(segment(O,L),segment(L,M),segment(M,N),segment(N,O));

fillcolor:=1.3green;
transparence section;

trace chemin(O,N) withcolor red  withpen pencircle scaled 1.5pt;
trace chemin(O,L,M,N) dashed evenly withcolor red;

nomme.top(L);
nomme.top(M);
nomme.top(N);
nomme.top(O);


nomme.llft(A);
nomme.bot(B);
nomme.rt(C);
nomme.ulft(D);
nomme.ulft(E);
nomme.lft(F);
nomme.lrt(G);
nomme.urt(H);

draw cadre withcolor black withpen pencircle scaled 2pt;
clip currentpicture to cadre;

finespace;

endfor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%0
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i:=15 upto 23:


figureespace(-20u,-20u,20u,20u);
Initialisation(a,b,c,d);

trace Cube(A,B,C,D,E,F,G,H);


color R,S,T,V;
V:=(0,0,i*0.1);
R:=I +V;
S:=J +V;
T:=K +V;



L:=IntersectionPlanDroite(R,S,T,D,A);
P:=IntersectionPlanDroite(R,S,T,C,B);
Q:=IntersectionPlanDroite(R,S,T,C,H);
N:=IntersectionPlanDroite(R,S,T,E,H);
O:=IntersectionPlanDroite(R,S,T,E,F);


path section;
section=buildcycle(segment(O,L),segment(L,P),segment(P,Q),segment(Q,N),segment(N,O));

fillcolor:=1.3blue;
transparence section;

trace chemin(O,N) withcolor red withpen pencircle scaled 1.5pt;
trace chemin(P,Q) withcolor red withpen pencircle scaled 1.5pt;
trace chemin(O,L,P) dashed evenly withcolor red;
trace chemin(Q,N) dashed evenly withcolor red;

nomme.top(L);
nomme.top(P);
nomme.top(Q);
nomme.top(N);
nomme.top(O);


nomme.llft(A);
nomme.bot(B);
nomme.rt(C);
nomme.ulft(D);
nomme.ulft(E);
nomme.lft(F);
nomme.lrt(G);
nomme.urt(H);

draw cadre withcolor black withpen pencircle scaled 2pt;
clip currentpicture to cadre;

finespace;

endfor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%0
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i:=24 upto 24:


figureespace(-20u,-20u,20u,20u);
Initialisation(a,b,c,d);

trace Cube(A,B,C,D,E,F,G,H);


color R,S,T,V;
V:=(0,0,i*0.1);
R:=I +V;
S:=J +V;
T:=K +V;



L:=IntersectionPlanDroite(R,S,T,D,A);
P:=IntersectionPlanDroite(R,S,T,C,B);
Q:=IntersectionPlanDroite(R,S,T,C,H);
N:=IntersectionPlanDroite(R,S,T,E,H);
O:=IntersectionPlanDroite(R,S,T,E,F);


path section;
section=buildcycle(segment(O,L),segment(L,P),segment(P,Q),segment(Q,N),segment(N,O));

fillcolor:=1.3green;
transparence section;

trace chemin(O,N) withcolor red withpen pencircle scaled 1.5pt;
trace chemin(P,Q) withcolor red withpen pencircle scaled 1.5pt;
trace chemin(O,L,P) dashed evenly withcolor red;
trace chemin(Q,N) dashed evenly withcolor red;

nomme.top(L);
nomme.top(P);
nomme.top(Q);
nomme.top(N);
nomme.top(O);


nomme.llft(A);
nomme.bot(B);
nomme.rt(C);
nomme.ulft(D);
nomme.ulft(E);
nomme.lft(F);
nomme.lrt(G);
nomme.urt(H);

draw cadre withcolor black withpen pencircle scaled 2pt;
clip currentpicture to cadre;


finespace;

endfor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%0
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i:=25 upto 33:


figureespace(-20u,-20u,20u,20u);
Initialisation(a,b,c,d);

trace Cube(A,B,C,D,E,F,G,H);


color R,S,T,V;
V:=(0,0,i*0.1);
R:=I +V;
S:=J +V;
T:=K +V;



L:=IntersectionPlanDroite(R,S,T,A,B);
P:=IntersectionPlanDroite(R,S,T,C,B);
M:=IntersectionPlanDroite(R,S,T,G,H);
Q:=IntersectionPlanDroite(R,S,T,A,F);
O:=IntersectionPlanDroite(R,S,T,E,F);


path section;
section=buildcycle(segment(O,Q),segment(Q,L),segment(L,P),segment(P,M),segment(M,O));

fillcolor:=1.3blue;
transparence section;

trace chemin(O,M,P) withcolor red withpen pencircle scaled 1.5pt;
trace chemin(Q,L) withcolor red withpen pencircle scaled 1.5pt;
trace chemin(O,Q) dashed evenly withcolor red;
trace chemin(L,P) dashed evenly withcolor red;

nomme.top(L);
nomme.top(P);
nomme.top(Q);
nomme.top(M);
nomme.top(O);


nomme.llft(A);
nomme.bot(B);
nomme.rt(C);
nomme.ulft(D);
nomme.ulft(E);
nomme.lft(F);
nomme.lrt(G);
nomme.urt(H);

draw cadre withcolor black withpen pencircle scaled 2pt;
clip currentpicture to cadre;

finespace;

endfor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%0
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i:=34 upto 43:


figureespace(-20u,-20u,20u,20u);
Initialisation(a,b,c,d);

trace Cube(A,B,C,D,E,F,G,H);


color R,S,T,V;
V:=(0,0,i*0.1);
R:=I +V;
S:=J +V;
T:=K +V;



L:=IntersectionPlanDroite(R,S,T,A,B);
P:=IntersectionPlanDroite(R,S,T,C,B);
M:=IntersectionPlanDroite(R,S,T,G,H);
N:=IntersectionPlanDroite(R,S,T,F,G);



path section;
section=buildcycle(segment(N,L),segment(L,P),segment(P,M),segment(M,N));

fillcolor:=1.3green;
transparence section;

trace chemin(L,N,M,P) withcolor red withpen pencircle scaled 1.5pt;
trace chemin(L,P) dashed evenly withcolor red;


nomme.top(L);
nomme.top(P);
nomme.top(M);
nomme.top(N);


nomme.llft(A);
nomme.bot(B);
nomme.rt(C);
nomme.ulft(D);
nomme.ulft(E);
nomme.lft(F);
nomme.lrt(G);
nomme.urt(H);

draw cadre withcolor black withpen pencircle scaled 2pt;
clip currentpicture to cadre;

finespace;

endfor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%0
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i:=44 upto 50:


figureespace(-20u,-20u,20u,20u);
Initialisation(a,b,c,d);

trace Cube(A,B,C,D,E,F,G,H);


color R,S,T,V;
V:=(0,0,i*0.1);
R:=I +V;
S:=J +V;
T:=K +V;




M:=IntersectionPlanDroite(R,S,T,G,H);
N:=IntersectionPlanDroite(R,S,T,F,G);
O:=IntersectionPlanDroite(R,S,T,B,G);


path section;
section=buildcycle(segment(M,N),segment(N,O),segment(O,M));

fillcolor:=1.3orange;
transparence section;

trace chemin(M,N,O,M) withcolor red withpen pencircle scaled 1.5pt;

nomme.top(O);
nomme.top(M);
nomme.top(N);


nomme.llft(A);
nomme.bot(B);
nomme.rt(C);
nomme.ulft(D);
nomme.ulft(E);
nomme.lft(F);
nomme.lrt(G);
nomme.urt(H);

draw cadre withcolor black withpen pencircle scaled 2pt;
clip currentpicture to cadre;

finespace;

endfor



%-----------------------------------------------------------------------
end ;