|  | 
| Supershapes (Superformula) Written by Paul Bourke
 March 2002
 Based upon equations by Johan Gielis
 Intended as a modelling framework for natural forms.
 
 
 See also Superellipse and Supershape in 3D
 
 
 
 
 
 --------------------------------------------------------------------------------
 
 
 The supershape equation is an extension of the both the equation of the sphere and ellipse
 
 (x / a)2 + (y / b)2 = r2
 and even the superellipse given here. The general formula for the supershape is given below.
 
 
 
 Where r and phi are polar coordinates (radius,angle). n1, n2, n3, and m are real numbers. a and b are real numbers excluding zero.
 
 m = 0
 This results in circles, namely r = 1
 n1 = n2 = n3 = 1
 Increasing m adds rotational symmetry to the shape. This is generally the case for other values of the n parameters. The curves are repeated in sections of the circle of angle 2pi/m, this is apparent in most of the following examples for integer values of m.  m=1 m=2
 m=3 m=4
 m=5 m=6
 
 n1 = n2 = n3 = 0.3
 As the n's are kept equal but reduced the form becomes increasingly pinched.  m=1 m=2
 m=3 m=4
 m=5 m=6
 
 If n1 is slightly larger than n2 and n3 then bloated forms result. The examples on the right have n1 = 40 and n2 = n3 = 10.  m=1 m=2
 m=3 m=4
 m=5 m=6
 
 Polygonal shapes are achieved with very large values of n1 and large but equal values for n2 and n3.  m=3 m=4
 m=5 m=6
 
 Asymmetric forms can be created by using different values for the n's. The following example have n1 = 60, n2 = 55 and n3 = 30.  m=3 m=4
 m=5 m=6
 
 For non integral values of m the form is still closed for rational values. The following are example with n1 = n2 = n3 = 0.3. The angle phi needs to extend from 0 to 12 pi.  m=1/6 m=7/6
 m=13/6 m=19/6
 
 Smooth starfish shapes result from smaller values of n1 than the n2 and n3. The following examples have m=5 and n2 = n3 = 1.7.  n1=0.50 n1=0.20
 n1=0.10 n1=0.02
 
 
 Other examples
 
 
 
 
 
 
 Source code
 Given a value of phi the following function evaluates the supershape function and calculates (x,y).
 
 
 void Eval(double m,double n1,double n2,double n3,double phi,double *x,double *y)
 {
 double r;
 double t1,t2;
 double a=1,b=1;
 
 t1 = cos(m * phi / 4) / a;
 t1 = ABS(t1);
 t1 = pow(t1,n2);
 
 t2 = sin(m * phi / 4) / b;
 t2 = ABS(t2);
 t2 = pow(t2,n3);
 
 r = pow(t1+t2,1/n1);
 if (ABS(r) == 0) {
 *x = 0;
 *y = 0;
 } else {
 r = 1 / r;
 *x = r * cos(phi);
 *y = r * sin(phi);
 }
 }
 
 So it might be called as follows
 
 
 for (i=0;i<=NP;i++) {
 phi = i * TWOPI / NP;
 Eval(m,n1,n2,n3,phi,&x,&y);
 --- do something with the point x,y ---
 }
 
 
 | 
 |