Strip extra spaces from code.
[voro++.git] / branches / dynamic / examples / basic / platonic.cc
blob663f3aab335923a5c4f4fcf5e66ce1976a118128
1 // Platonic solids example code
2 //
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : July 1st 2008
7 #include "voro++.cc"
9 // Golden ratio constants
10 const double Phi=0.5*(1+sqrt(5.0));
11 const double phi=0.5*(1-sqrt(5.0));
13 int main() {
14 voronoicell v;
16 // Create a tetrahedron
17 v.init(-2,2,-2,2,-2,2);
18 v.plane(1,1,1);
19 v.plane(1,-1,-1);
20 v.plane(-1,1,-1);
21 v.plane(-1,-1,1);
23 v.draw_gnuplot("tetrahedron.gnu",0,0,0);
25 // Create a cube. Since this is the default shape
26 // we don't need to do any plane cutting.
27 v.init(-1,1,-1,1,-1,1);
28 v.draw_gnuplot("cube.gnu",0,0,0);
30 // Create an octahedron
31 v.init(-2,2,-2,2,-2,2);
32 v.plane(1,1,1);
33 v.plane(-1,1,1);
34 v.plane(1,-1,1);
35 v.plane(-1,-1,1);
36 v.plane(1,1,-1);
37 v.plane(-1,1,-1);
38 v.plane(1,-1,-1);
39 v.plane(-1,-1,-1);
41 v.draw_gnuplot("octahedron.gnu",0,0,0);
43 // Create a dodecahedron
44 v.init(-2,2,-2,2,-2,2);
45 v.plane(0,Phi,1);
46 v.plane(0,-Phi,1);
47 v.plane(0,Phi,-1);
48 v.plane(0,-Phi,-1);
49 v.plane(1,0,Phi);
50 v.plane(-1,0,Phi);
51 v.plane(1,0,-Phi);
52 v.plane(-1,0,-Phi);
53 v.plane(Phi,1,0);
54 v.plane(-Phi,1,0);
55 v.plane(Phi,-1,0);
56 v.plane(-Phi,-1,0);
58 v.draw_gnuplot("dodecahedron.gnu",0,0,0);
60 // Create an icosahedron
61 v.init(-2,2,-2,2,-2,2);
62 v.plane(1,1,1);
63 v.plane(-1,1,1);
64 v.plane(1,-1,1);
65 v.plane(-1,-1,1);
66 v.plane(1,1,-1);
67 v.plane(-1,1,-1);
68 v.plane(1,-1,-1);
69 v.plane(-1,-1,-1);
70 v.plane(0,phi,Phi);
71 v.plane(0,phi,-Phi);
72 v.plane(0,-phi,Phi);
73 v.plane(0,-phi,-Phi);
74 v.plane(Phi,0,phi);
75 v.plane(Phi,0,-phi);
76 v.plane(-Phi,0,phi);
77 v.plane(-Phi,0,-phi);
78 v.plane(phi,Phi,0);
79 v.plane(phi,-Phi,0);
80 v.plane(-phi,Phi,0);
81 v.plane(-phi,-Phi,0);
83 v.draw_gnuplot("icosahedron.gnu",0,0,0);