### Fiddles

A Superellipsoid or super-egg. You can control the shape using these values: r t A B C

The default values give Piet Hein's superegg. Other interesting cases to try are:

• r=2, t=2, ellipsoids
• r=1, t=1, octohedra
• r=0.7, t=0.7, pointy stars.

Superellipsoids are three dimensional versions of superellipses which in turn are a cross between a square and a circle. A circle has equation $x^2+y^2=1$ if we generalise that we get the superellipses $x^p+y^p=1$. You can play with the 2D version parametric version (faster) implicit verson (slower).

The equation for the superellipsoid is $\left(\left|{\frac {x}{A}}\right|^{r}+\left|{\frac {y}{B}}\right|^{r}\right)^{{t/r}}+\left|{\frac {z}{C}}\right|^{{t}}=1$. To generate the mesh I have started with a mesh on a cube, project them onto a sphere, and find the spherical coordinates, $\rho=\sqrt{x^2+y^2+z^2}$, $\theta=\mathrm{atan2}(y,x)$, $\phi=\mathrm{asin}(z/\rho)$. Using the polar representation for the superellipse \begin{align} X(\theta,\phi)=&A\,c(\phi,2/t)\ c(\theta,2/r)\\ Y(\theta,\phi)=&B\,c(\phi,2/t)\ s(\theta,2/r)\\ Z(\theta,\phi)=&C\,s(\phi,2/t). \end{align} Where $c(v,t) = \operatorname{sgn}(\cos v )|\cos v |^{t}$, $s(v,t) = \operatorname{sgn}(\sin v )|\sin v |^{t}$. This simplifies to \begin{align} X(x,y,z) = &A\,p(m/\rho,2/t)\ p(x/m,2/r)\\ X(x,y,z) = &B\,p(m/\rho,2/t)\ p(y/m,2/r)\\ X(x,y,z) = &C\,p(z/\rho,2/t)\\ \end{align} with $p(v,t)=\operatorname{sgn}(v )|v|^{t}$ and $m=\sqrt{x^2+y^2}$. See this answer at stackoverflow.

### Definition of the theta and phi

Yibin Jiang Mon Nov 19 2018

The definition of theta and phi can be varied according to t and r. Theta is not always defined by atan2(x,y), neither as phi.