clear;

//==========================================================================================
//Tracé d'un dodécaèdre régulier
//==========================================================================================

phi = (1+sqrt(5))/2; //Nombre d'or

//==========================================================================================
//Liste des 20 sommets
//==========================================================================================

S1 = [1;1;1];
S2 = [1;1;-1];
S3 = [1;-1;1];
S4 = [1;-1;-1];
S5 = [-1;1;1];
S6 = [-1;1;-1];
S7 = [-1;-1;1];
S8 = [-1;-1;-1];

S9 = [phi;1/phi;0];
S10 = [phi;-1/phi;0];
S11 = [-phi;1/phi;0];
S12 = [-phi;-1/phi;0];

S13 = [0;phi;1/phi];
S14 = [0;phi;-1/phi];
S15 = [0;-phi;1/phi];
S16 = [0;-phi;-1/phi];

S17 = [1/phi;0;phi];
S18 = [-1/phi;0;phi];
S19 = [1/phi;0;-phi];
S20 = [-1/phi;0;-phi];

//==========================================================================================
//Tracé du dodécaèdre
//==========================================================================================

f0=scf(1);
clf();
List1 = [S1,S2,S3,S4,S5,S6,S7,S8,S1];
scatter3d(List1(1,:),List1(2,:),List1(3,:),"markerEdgeColor", "red","markerFaceColor","red");
List2 = [S9,S10,S11,S12,S9];
scatter3d(List2(1,:),List2(2,:),List2(3,:),"markerEdgeColor", "green","markerFaceColor","green");
List3 = [S13,S14,S15,S16,S13];
scatter3d(List3(1,:),List3(2,:),List3(3,:),"markerEdgeColor", "blue","markerFaceColor","blue");
List4 = [S17,S18,S19,S20,S17];
scatter3d(List4(1,:),List4(2,:),List4(3,:),"markerEdgeColor", "orange","markerFaceColor","orange");
gca().grid=[-1,-1];

AList1 = [S1,S17,S3,S10,S9,S1];
AList2 = [S13,S18,S15,S4,S2];
AList3 = [S5,S7,S16,S19,S14];
AList3bis = [S14,S5,S7,S16,S19];
AList4 = [S11,S12,S8,S20,S6,S11];
param3d(AList1(1,:),AList1(2,:),AList1(3,:),30, 72,"X@Y@Z",[4,4]);
e=gce();
e.thickness=3;
param3d(AList4(1,:),AList4(2,:),AList4(3,:),30, 72,"X@Y@Z",[4,4]);
e=gce();
e.thickness=3;
for j=1:5
    Q2 = [AList1(:,j),AList2(:,j)];
    Q3 = [AList2(:,j),AList3(:,j)];
    Q3bis = [AList2(:,j),AList3bis(:,j)];
    Q4 = [AList3(:,j),AList4(:,j)];
    param3d(Q2(1,:),Q2(2,:),Q2(3,:),30, 72,"X@Y@Z",[4,4]);
    e=gce();
    e.thickness=3;
    param3d(Q3(1,:),Q3(2,:),Q3(3,:),30, 72,"X@Y@Z",[4,4]);
    e=gce();
    e.thickness=3;
    param3d(Q3bis(1,:),Q3bis(2,:),Q3bis(3,:),30, 72,"X@Y@Z",[4,4]);
    e=gce();
    e.thickness=3;
    param3d(Q4(1,:),Q4(2,:),Q4(3,:),300, 72,"X@Y@Z",[4,4]);
    e=gce();
    e.thickness=3;
end
title('Construction du dodécaèdre régulier');

//==========================================================================================
//Tracé des cinq cubes inscrits
//==========================================================================================

f1=scf(2);

clf();
List1 = [S1,S2,S3,S4,S5,S6,S7,S8,S1];
scatter3d(List1(1,:),List1(2,:),List1(3,:),"markerEdgeColor", "black","markerFaceColor","black");
List2 = [S9,S10,S11,S12,S9];
scatter3d(List2(1,:),List2(2,:),List2(3,:),"markerEdgeColor", "black","markerFaceColor","black");
List3 = [S13,S14,S15,S16,S13];
scatter3d(List3(1,:),List3(2,:),List3(3,:),"markerEdgeColor", "black","markerFaceColor","black");
List4 = [S17,S18,S19,S20,S17];
scatter3d(List4(1,:),List4(2,:),List4(3,:),"markerEdgeColor", "black","markerFaceColor","black");
gca().grid=[-1,-1];
param3d(S1(1),S1(2),S1(3),300, 72,"X@Y@Z",[4,4]);

CList1 = [S1,S2,S3,S4,S5,S6,S7,S8, S1,S3,S2,S4,S5,S7,S6,S8, S1,S5,S2,S6,S3,S7,S4,S8];
CList2 = [S1,S10,S18,S15,S14,S19,S11,S8, S1,S18,S10,S15,S14,S11,S19,S8, S1,S14,S10,S19,S18,S11,S15,S8];
CList3 = [S2,S13,S20,S11,S10,S17,S16,S7, S2,S20,S13,S11,S10,S16,S17,S7, S2,S10,S13,S17,S20,S16,S11,S7];
CList4 = [S17,S9,S4,S15,S12,S20,S5,S14, S17,S15,S9,S4,S12,S5,S20,S14, S17,S5,S9,S14,S15,S12,S4,S20];
CList5 = [S18,S13,S3,S9,S16,S19,S12,S6, S18,S3,S13,S9,S16,S12,S19,S6, S18,S12,S9,S19,S3,S16,S13,S6];
xsegs(CList1(1,:),CList1(2,:),CList1(3,:),color('red'));
e=gce();
e.thickness=3;
xsegs(CList2(1,:),CList2(2,:),CList2(3,:),color('green'));
e=gce();
e.thickness=3;
xsegs(CList3(1,:),CList3(2,:),CList3(3,:),color('orange'));
e=gce();
e.thickness=3;
xsegs(CList4(1,:),CList4(2,:),CList4(3,:),color('blue'));
e=gce();
e.thickness=3;
xsegs(CList5(1,:),CList5(2,:),CList5(3,:),color('magenta'));
e=gce();
e.thickness=3;
title('Cubes inscrits du dodécaèdre');

