Strip extra spaces from code.
[voro++.git] / branches / exact / examples / degenerate / degenerate.cc
blobc997b02a00f2ad19736b9cbf2f7ee385d344451a
1 // Degenerate Voronoi cell 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 const double pi=3.1415926535897932384626433832795;
12 // The number of planes to be cut around each coordinate axis
13 const int n=32;
14 const double step=2*pi/n;
16 // The angle (in radians) of the cutting planes from horizontal
17 const double theta=pi/4-0.25;
19 int main() {
20 double x,y,z,phi;
21 voronoicell v;
23 // Initialize the Voronoi cell to be a cube of side length 2, centered
24 // on the origin
25 v.init(-1,1,-1,1,-1,1);
27 // Plane cutting
28 for(phi=0;phi<2*pi-0.5*step;phi+=step) {
29 x=cos(theta);y=cos(phi)*sin(theta);z=sin(phi)*sin(theta);
30 v.plane(x,y,z,1);
31 v.plane(-x,y,z,1);
32 v.plane(y,x,z,1);
33 v.plane(y,-x,z,1);
34 v.plane(y,z,x,1);
35 v.plane(y,z,-x,1);
38 // Check that the relation table is correct, and that there are no
39 // duplicate edges
40 v.check_relations();
41 v.check_duplicates();
43 // Output the Voronoi cell to a file in Gnuplot format
44 v.draw_gnuplot(0,0,0,"degenerate.gnu");
46 // Output the Voronoi cell to a file in POV-Ray format
47 v.draw_pov(0,0,0,"degenerate_v.pov");