1 // Superellipsoid example code
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : July 1st 2008
9 // This function returns a random floating point number between 0 and 1
10 double rnd() {return double(rand())/RAND_MAX
;}
16 // Initialize the Voronoi cell to be a cube of side length 2, centered
18 v
.init(-1,1,-1,1,-1,1);
20 // Cut the cell by 5000 random planes that are scaled to create a
22 for(int i
=0;i
<5000;i
++) {
26 rsq
=x
*x
*x
*x
+y
*y
*y
*y
+z
*z
*z
*z
;
30 v
.plane(x
*x
*x
,y
*y
*y
,z
*z
*z
,x
*x
*x
*x
+y
*y
*y
*y
+z
*z
*z
*z
);
34 // Output the Voronoi cell to a file, in the gnuplot format
35 v
.draw_gnuplot("superellipsoid.gnu",0,0,0);
37 // Output the Voronoi cell to a file in POV-Ray formats
38 v
.draw_pov("superellipsoid_v.pov",0,0,0);
39 v
.draw_pov_mesh("superellipsoid_m.pov",0,0,0);