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

 

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 ---
   }



Supershape in 3D

(Also known as the Superformula)

Written by Paul Bourke
July 2003

Based upon equations by Johan Gielis
Intended as a modelling framework for natural forms.

Contribution of MSWindows version by Vincent Berthoux: supershape_win.zip

Table of contents

Software
Examples
Non integer m
2D
Extrusion
Stability
Classical forms
Shells
Toroidal mapping
Renderings
Physical model

Definition of supershape in 2 dimensions.

Extension to 3D using the spherical product.

Software

The following shows the interface developed to explore 3D supershapes. It is based upon X-Windows and OpenGL and as such is interactive. It is currently available for Mac OS-X (as a UNIX application) upon payment of a US$30 shareware fee. Use of the program is straightforward, edit fields and hit return. The left mouse button rotates the model in two axes, the middle mouse button rotates about the third axis. The right mouse button brings up a menu.


Click for full size image

Command line interface

Many settings can be intialised from the command line, others control is given by single key strokes. To see a complete list type the program name at the command prompt with a "-h" option. At the time of writing these are given below.

>supershape -h
Usage: supershape [command line options]
Command line options
            -h   this text
            -f   full screen
            -s   active stereo
           -ss   dual screen stereo
            -a   auto rotate
           -rw   wireframe
           -rs   flat shaded
           -rp   specular shaded
Mouse buttons
          left   camera rotate
    shift left   camera pan
        middle   camera roll
  shift middle   camera forward, reverse

Key Strokes
    arrow keys   camera rotate
           <,>   camera forward, reverse
           +,-   camera zoom in, out
           [,]   camera roll
             r   toggle window recording
             w   capture window to TGA file
             a   toggle auto rotation of camera
         1,2,3   different rendering mode
             h   camera to home position
      f1 to f6   axis aligned camera positions
         ESC,q   quit
Features

  • Exports geometry as DXF, POVRay, and LightWave (the later includes texture coordinates).

  • Rendering modes include wireframe, flat shaded, and specular shading. Rendering is based upon OpenGL.

  • Colour ramps can be applied to both longitude and latitude.

  • Parameter space exploration by either single parameter ranges or simply choosing a random parameter set.

  • A supershape can be morphed into another.

  • Images can be saved to a single TGA file or repreated saving can be turned on for animations. TGA files and the naming convention used are supported by QuickTime Pro.

Examples

Non integer values of m

2D

The 2D supershapes (but with added small thickness) can be created using this software by setting the second supershape parameters as m=0, n1=n2=n3=1, a=b=1 and using a small z axis scale factor. Indeed this can often be the preferred approach for using a 2D form within a 3D model, after all, real world objects do have some thickness. The example on the left has a thickness of 0.02 units (x and y axis dimensions of 1). Or even set the depth to 0 and vary latitude from 0 to 90 degrees as in the example on the right.

Extrusion

Extrusions of 2D supershapes can be created by setting the second supershape parameters as m=4, a=1, b=1, and high equal values for each of n1,n2,n3. For example n1=n2=n3=200 gives relatively sharp edges.

Stability

A significant portion of the parameter space results in surfaces with various types of numerical problems (powers of negative numbers, divide by 0, underflow, overflow, etc) as well as issues related to the representation of 3D graphics. The software that has been developed and created the images shown above, can display the edges where numerical problems have arisen. These regions are shown in pick as shown in the following two images.

Classical shapes

Cube

Cone

Diamond

Sphere

Prism

Cylinder

Hexagon

Pentagon

Shells

The supershape function can obviously be modulated by another function. For example to create the shell like structures below, the radius (r1) of the superformula that varies the longitude is scaled by either a logarithmic or Archimedes spiral. In some cases the z coordinate is additionally made a linear function of longitude.

Toroidal mapping

In the above the two supershapes were mapped onto a topological sphere. One could map supershapes onto other forms as well, for example, a torus. In the following images the mapping is as follows:

Renderings


Contribution by Luc Benard


Contributions by Albert Kiefer

Physical models




Generating the 3D Supershape in Povray

Written by Paul Bourke
July 2003

Based upon equations by Johan Gielis
Intended as a modelling framework for natural forms.

There are two (at least) ways of representing supershapes using PovRay. One is to use the builtin parametric primitive, doing it this way would result in the highest resolution/quality results unfortunately the rendering times proved to be prohibitive. The approach illustrated below is to write a macro in the PovRay scene language. The macro and an example of it's use is given in this PovRay (version 3.5) file: supershape.pov.


SuperShape(9,1,1,92,0.3,-45,4,1,1,-0.8,88,-0.35,202)

SuperShape(1,1,1,77,0.81,71.7,8,1,1,0.63,2.92,0.24,200)

SuperShape(9,1,1,-70,-0.14,77,2,1,1,0.38,4.12,-0.7,200)

SuperShape(7,1,1,20.45,-0.33,-3.54,6,1,1,-0.96,4.46,0.52,200)

Further POVRay scene examples are given below
    ss_macro1.inc example1.pov
    ss_macro2.inc example2.pov
    ss_macro3.inc example3.pov
      example4.pov

Contributions from the POVRay competition

Author: SpB
Title: Flying wing
Source: 0001.pov
Author: Dalius Dobravolskas
Title: Lost in the sea
Source: 0002.pov
Author: Paul Bourke
Title: Supershape fractal
Source: 0003.pov
Author: Stefano Tessarin
Title: Flowers
Source: 0004.pov
Author: Emanuele Munarini
Source: 0005.pov
Author: Emanuele Munarini
Source: 0006.pov
Author: Emanuele Munarini
Source: 0007.pov
Author: Emanuele Munarini
Source: 0008.pov
Author: Ben Scheele
Title: Butterflies find cactus flowers in a desert
Source: 0009.pov