1 // Simple cell statistics demonstration code
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
10 // This function returns a random floating point number between 0 and 1
11 double rnd() {return double(rand())/RAND_MAX
;}
17 // Initialize the Voronoi cell to be a cube of side length 2, centered
19 v
.init(-1,1,-1,1,-1,1);
21 // Remove one edge of the cell with a single plane cut
24 // Output the Voronoi cell to a file in gnuplot format
25 v
.draw_gnuplot(0,0,0,"simple_cell.gnu");
27 // Output vertex-based statistics
28 printf("Total vertices : %d\n",v
.p
);
29 printf("Vertex positions : ");v
.output_vertices();puts("");
30 printf("Vertex orders : ");v
.output_vertex_orders();puts("");
31 printf("Max rad. sq. vertex : %g\n\n",0.25*v
.max_radius_squared());
33 // Output edge-based statistics
34 printf("Total edges : %d\n",v
.number_of_edges());
35 printf("Total edge distance : %g\n",v
.total_edge_distance());
36 printf("Face perimeters : ");v
.output_face_perimeters();puts("\n");
38 // Output face-based statistics
39 printf("Total faces : %d\n",v
.number_of_faces());
40 printf("Surface area : %g\n",v
.surface_area());
41 printf("Face freq. table : ");v
.output_face_freq_table();puts("");
42 printf("Face orders : ");v
.output_face_orders();puts("");
43 printf("Face areas : ");v
.output_face_areas();puts("");
44 printf("Face normals : ");v
.output_normals();puts("");
45 printf("Face vertices : ");v
.output_face_vertices();puts("\n");
47 // Output volume-based statistics
49 printf("Volume : %g\n"
50 "Centroid vector : (%g,%g,%g)\n",v
.volume(),x
,y
,z
);