1 #include "voro++_2d.hh"
4 // This function returns a random floating point number between 0 and 1
5 double rnd() {return double(rand())/RAND_MAX
;}
11 // Initialize the Voronoi cell to be a cube of side length 2, centered
15 // Cut the cell by 100 random planes which are all a distance 1 away
16 // from the origin, to make an approximation to a sphere
17 for(int i
=0;i
<100;i
++) {
22 r
=1/sqrt(rsq
);x
*=r
;y
*=r
;
27 // Print out several statistics about the computed cell
29 printf("Perimeter is %g\n"
31 "Centroid is (%g,%g)\n",v
.perimeter(),v
.area(),x
,y
);
33 // Output the Voronoi cell to a file, in the gnuplot format
34 v
.draw_gnuplot(0,0,"single_cell_2d.gnu");