summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/asymptote/examples/truncatedIcosahedron.asy
blob: e4d07a49e5ba98c8d8cb9b160e977a5f2ccad9de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import graph3;

size(200);

defaultrender.merge=true;

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 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(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(surface(reverse(operator--(...fiveout)--cycle)^^
               operator--(...fivein)--cycle,planar=true),cyan);
}