Strip extra spaces from code.
[voro++.git] / branches / exact / examples / basic / platonic.cc
blob4e8aa5bd92255a3485943781c427d342251c94ca
1 // Platonic solids example code
2 //
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
7 #include "voro++.hh"
8 using namespace voro;
10 // Golden ratio constants
11 const double Phi=0.5*(1+sqrt(5.0));
12 const double phi=0.5*(1-sqrt(5.0));
14 int main() {
15 voronoicell v;
17 // Create a tetrahedron
18 v.init(-2,2,-2,2,-2,2);
19 v.plane(1,1,1);
20 v.plane(1,-1,-1);
21 v.plane(-1,1,-1);
22 v.plane(-1,-1,1);
24 v.draw_gnuplot(0,0,0,"tetrahedron.gnu");
26 // Create a cube. Since this is the default shape
27 // we don't need to do any plane cutting.
28 v.init(-1,1,-1,1,-1,1);
29 v.draw_gnuplot(0,0,0,"cube.gnu");
31 // Create an octahedron
32 v.init(-2,2,-2,2,-2,2);
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);
40 v.plane(-1,-1,-1);
42 v.draw_gnuplot(0,0,0,"octahedron.gnu");
44 // Create a dodecahedron
45 v.init(-2,2,-2,2,-2,2);
46 v.plane(0,Phi,1);
47 v.plane(0,-Phi,1);
48 v.plane(0,Phi,-1);
49 v.plane(0,-Phi,-1);
50 v.plane(1,0,Phi);
51 v.plane(-1,0,Phi);
52 v.plane(1,0,-Phi);
53 v.plane(-1,0,-Phi);
54 v.plane(Phi,1,0);
55 v.plane(-Phi,1,0);
56 v.plane(Phi,-1,0);
57 v.plane(-Phi,-1,0);
59 v.draw_gnuplot(0,0,0,"dodecahedron.gnu");
61 // Create an icosahedron
62 v.init(-2,2,-2,2,-2,2);
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(-1,-1,-1);
71 v.plane(0,phi,Phi);
72 v.plane(0,phi,-Phi);
73 v.plane(0,-phi,Phi);
74 v.plane(0,-phi,-Phi);
75 v.plane(Phi,0,phi);
76 v.plane(Phi,0,-phi);
77 v.plane(-Phi,0,phi);
78 v.plane(-Phi,0,-phi);
79 v.plane(phi,Phi,0);
80 v.plane(phi,-Phi,0);
81 v.plane(-phi,Phi,0);
82 v.plane(-phi,-Phi,0);
84 v.draw_gnuplot(0,0,0,"icosahedron.gnu");