1 // Superellipsoid example 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 // Cut the cell by 5000 random planes that are scaled to create a
23 for(int i
=0;i
<5000;i
++) {
27 rsq
=x
*x
*x
*x
+y
*y
*y
*y
+z
*z
*z
*z
;
31 v
.plane(x
*x
*x
,y
*y
*y
,z
*z
*z
,x
*x
*x
*x
+y
*y
*y
*y
+z
*z
*z
*z
);
35 // Output the Voronoi cell to a file, in the gnuplot format
36 v
.draw_gnuplot(0,0,0,"superellipsoid.gnu");
38 // Output the Voronoi cell to a file in POV-Ray formats
39 v
.draw_pov(0,0,0,"superellipsoid_v.pov");
40 v
.draw_pov_mesh(0,0,0,"superellipsoid_m.pov");