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