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
;}
9 voronoicell_nonconvex_2d v
;
11 // Initialize the Voronoi cell to be a cube of side length 2, centered
13 v
.init_nonconvex(-1,0.8,-1,0.4,4,5,5,4);
14 v
.draw_gnuplot(0,0,"nonconvex_cell.gnu");
18 // Cut the cell by 100 random planes which are all a distance 1 away
19 // from the origin, to make an approximation to a sphere
20 /*for(int i=0;i<100;i++) {
25 r=1/sqrt(rsq);x*=r;y*=r;
30 // Print out several statistics about the computed cell
32 printf("Perimeter is %g\n"
34 "Centroid is (%g,%g)\n",v
.perimeter(),v
.area(),x
,y
);
36 // Output the Voronoi cell to a file, in the gnuplot format
37 v
.draw_gnuplot(0,0,"nonconvex_cell2.gnu");