Reset platonic code.
[voro++.git] / trunk / examples / basic / platonic.cc
blob76dade5fa1663901eb61e441712abfab3a239325
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);
23 v.draw_gnuplot(0,0,0,"tetrahedron.gnu");
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(0,0,0,"cube.gnu");
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);
40 v.draw_gnuplot(0,0,0,"octahedron.gnu");
42 // Create a dodecahedron
43 v.init(-2,2,-2,2,-2,2);
44 v.plane(0,Phi,1);
45 v.plane(0,-Phi,1);
46 v.plane(0,Phi,-1);
47 v.plane(0,-Phi,-1);
48 v.plane(1,0,Phi);
49 v.plane(-1,0,Phi);
50 v.plane(1,0,-Phi);
51 v.plane(-1,0,-Phi);
52 v.plane(Phi,1,0);
53 v.plane(-Phi,1,0);
54 v.plane(Phi,-1,0);
55 v.plane(-Phi,-1,0);
57 v.draw_gnuplot(0,0,0,"dodecahedron.gnu");
59 // Create an icosahedron
60 v.init(-2,2,-2,2,-2,2);
61 v.plane(1,1,1);
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(0,phi,Phi);
70 v.plane(0,phi,-Phi);
71 v.plane(0,-phi,Phi);
72 v.plane(0,-phi,-Phi);
73 v.plane(Phi,0,phi);
74 v.plane(Phi,0,-phi);
75 v.plane(-Phi,0,phi);
76 v.plane(-Phi,0,-phi);
77 v.plane(phi,Phi,0);
78 v.plane(phi,-Phi,0);
79 v.plane(-phi,Phi,0);
80 v.plane(-phi,-Phi,0);
82 v.draw_gnuplot(0,0,0,"icosahedron.gnu");