Home Cooking XML Page Civil War Letters Art

# The Universal Egg Equation

A paper recently came to my attention about the shape of (avian) eggs[1]. The paper is very readable.

It turns out, bird eggs come in a variety of shapes: round (like ostrich eggs), elliptical (like emu eggs), a flattened oval (like chicken eggs), and pyriform (more pointed with flatter sides, like guillemot eggs).

The tradition, in the egg-equation community, is to define these shapes using 2 dimensional equations, where x ranges over the length of the egg, and y is a function of x, polynomial over x.

Thus the equations for circles and ellipses look a little peculiar.

Circle: `y = ±√((L²/4)-x²)`

Ellipse: `y = ±(B/L)√((L²/4)-x²)`

`L` is the length of the egg and `B` is the breadth, which is no greater than the length.

The derivation isn't that complicated: The circle has a radius of `L/2`. Plugging that into the conventional Cartesian equation for a circle (`x² + y² = r²`) and solving for `y` gives us the result above. Similarly for ellipses.

For the diagram above I rotated the egg 90 degrees and applied a gradient colouring. This gives the illusion of depth, but the equation is strictly two dimensional. The actual three dimensional object rotates this same shape around the axis, as eggs are symmetrical in this way.

The equation for the classic oviform egg (the flattened oval), is a little more complicated:

```          y = ±(B/2) √((L²-4x²) / (L²+8wx+4w²))
```

The new parameter, `w` captures the degree of flattening. For realistic eggs, the paper uses the formula `w = (L - B)/2n` where `n` is a positive number. Lower values of `n` give higher values of `w`, i.e. more flattening.

This diagram shows the effect of `w` as `n` increases from 1 (top left) to 20 (bottom right):

The equation for a pyriform egg (the pointy eggs), is even more involved:

```          y = ±(B/2) √((L²-4x²)L / (2(L-2w)x² + (L²+8wL+4w²)x + 2Lw² + L²w + L³))
```

Finally, the universal egg equation, which encompasses all these egg shapes, is something of a monster:

```          y = ±(B/2) √((L²-4x²) / (L²+8wx+4w²)) /
(1 - (
(√(5.5L²+11Lw+4w²) (√3 BL-2D√(L²+2wL+4w²))) /
(√3 BL(√(5.5L²+11Lw+4w²) - 2√(L²+2wL+4w²)))
)
(1 -
√(
(L(L²+8wx+4w²)) /
(2(L-2w)x² + (L²+8Lw-4w²)x + 2Lw² + L²w + L³)
)
)
)
```

If we pull out a few constants in `L` and `w`, it becomes slightly more manageable:

```          α = L²+4w²
β = L²+2wL+4w² = α+2wl
γ = L²+8wL-4w²
δ = 5.5L²+11Lw+4w²
ε = 2Lw²+L²w+L³

y = ±(B/2) √((L²-4x²)/(8wx+α)) /
(1 - ((√δ (√3 BL-2D√β)) / (√3 BL(√δ - 2√β)))
(1 - √((L(8wx+α)) / (2(L-2w)x² + γx + ε)))
)
```

There is yet another new parameter here, `D`, which is defined as the diameter of the egg at the point `L/4` from the pointed end of the egg. It should be less than the breadth. This parameter captures the pointiness of the egg.

Ratios less than 0.5 aren't realistic as actual eggs. This diagram shows the effect of varying the ratio of `B` to `D` from 0.05 (top left) to 1.0 (bottom right). Things go badly awry for the smaller ratios. Interestingly, things get a little weird for the higher ratios too: the pointy end becomes the blunt end!

## Reparameterizing

All respect to egg scientists, `w` and `D` don't actually mean much to me. Nor do I want to think about `B` as independent of `L`. To implement my own egg-drawing code, I reparameterized. For me, and egg is defined by three shape parameters plus a basic scaling parameter:

size
Length of the egg (`L`)
roundness
Ratio of `B` to `L`
pointiness
Ratio of `D` to `B`
flattening
Flattening of the bottom of the egg: `n` in the `w` equation

An egg descriptor is defined in terms of roundness, pointiness, and flattening, and functions can calculate a polygon approximating the shape given the size and a precision for the approximation (number of sides of the polygon, essentially). I can then create the same shape egg in different sizes. I also have different functions to generate the round, elliptical, oviform, pyriform, or full avian shape by applying the appropriate formula to the egg descriptor. (Obviously not all the parameters apply to all the formulas.) This is what made the first picture above.

Given the ability to draw a polygon, now we can use it to make art. Eggs in a messy nest, cosmic eggs:

To give the effect of depth in the egg clutch, the eggs are rendered with those higher up the page first (height as a proxy for depth, in other words) and each egg polygon is filled with a circular gradient whose center is located at point towards the top of the canvas. I'm using ordered perceptually uniform gradients that run from light to dark to give this sense of shading.