summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/polyhedra.xp
blob: c2a788986e571bf6e5bc5b47684756ff1fffd187 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

// compile with, e.g., elaps -DALL polyhedra.xp

const double MAX(1.25);

#define A5

// draw everyone
#ifdef ALL
#define A4
#define A5
#endif /* ALL */

// draw three polyhedra with A4 symmetry
#ifdef A4
#define COLOR
#define TETRA
#define CUBE
#define OCTA
#endif /* A4 */

// draw two polyhedra with A5 symmetry
#ifdef A5
#ifndef COLOR
#define COLOR
#endif /* ndef COLOR */
#define DODECA
#define ICOSA
#endif /* A5 */

int main()
{
  picture(P(-MAX,-MAX),P(MAX,MAX), "6 x 6in");

  begin();
  const double gam(0.5*(1+sqrt(5)));

  grid();
  camera.at(P(8,3,2));
  camera.range(20);

  Sphere S;
  frame f;
  frame f2(E_2, E_1, E_3);

#ifdef TETRA
#ifdef COLOR
  rgb(1,0.7,0.7);
#endif /* COLOR */
  back_tetra(S, f);
  back_tetra(S, f2);
#endif

#ifdef CUBE
#ifdef COLOR
  rgb(0.7,0.7,1);
#endif /* COLOR */
  back_cube(S, f);
#endif

#ifdef OCTA
#ifdef COLOR
  rgb(0.7,1,0.7);
#endif /* COLOR */
  back_octa(S, f);
#endif

#ifdef DODECA
#ifdef COLOR
  rgb(0.7,1,1);
#endif /* COLOR */
  back_dodeca(S, f);
#endif

#ifdef ICOSA
#ifdef COLOR
  rgb(1,1,0.7);
#endif /* COLOR */
  back_icosa(S, f);
#endif

  bold();

#ifdef TETRA
#ifdef COLOR
  red();
#endif /* COLOR */
  front_tetra(S, f);
  front_tetra(S, f2);
#endif

#ifdef CUBE
#ifdef COLOR
  blue();
#endif /* COLOR */
  front_cube(S, f);
#endif

#ifdef OCTA
#ifdef COLOR
  green(0.6);
#endif /* COLOR */
  front_octa(S, f);
#endif

#ifdef DODECA
#ifdef COLOR
  rgb(0, 0.7, 0.7);
#endif /* COLOR */
  front_dodeca(S, f);
#endif

#ifdef ICOSA
#ifdef COLOR
  rgb(1, 0.9, 0);
#endif /* COLOR */
  front_icosa(S, f);
#endif

#ifdef COLOR
  green(0.8);
#endif
  S.draw();

  end();
}