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