# Klein bottle parameterization

The Klein bottle is a closed surface which has no inside or outside. In 3D space, it intersects itself. Klein bottles make for nice demonstrations of 3D objects: they look strange, yet realistic, and intersections reveals the quality of the 3D renderer.

Searching for a nice parameterization of a Klein bottle has not given a satisfactory one, i.e. a smooth object, visually pleasant, made of a single set of equations. For instance, in September 2007, two parameterizations are used to illustrate the Klein bottle articles at MathWorld and Wikipedia: one with a very noticeable discontinuity in the thicker part, and one made of four connected simple geometries.

Our goal is to have a smooth parameterization. The key idea is
to extrude a circle along a path, choosing carefully the path, the
circle radius and the circle orientation. The motion along the
path is parameterized by *u* and the circle by *v*,
both in [0, 2 pi].

This parameterization relies on three scalar values. Thanks to Sysquake Remote, you can change them here and update all the graphics below, or reset default values. Note that you should probably read this document entirely first.

**1. Path**

The path must look like this:

It can be defined as

*x* = sin *u* - 0.5 sin 2*u*

*y* = -*h* cos *u*

**2. Radius of cross-section circle**

The cross-section radius must be larger on the right path than on the left path. We define it as

*r* = *r0* (1 + *d* sin *u*)

**3. Cross-section plane**

The plane where the cross-section lies for a given value
of *u* is perpendicular to the path. Its normal vector
is obtained by differentiating the path equation and is normalized.
Beware the singularity for *u*=0 and *u*=2pi.

**4. Klein bottle equations**

This results in the following equations for the Klein bottle:

*a* = sqrt((cos *u* - cos 2*u*)^2 + (*h* sin *u*)^2)

*r* = *r0* (1 + *d* sin *u*)

*x* = sin(*u*) - 0.5 * sin 2*u* + *h* *r* sin *u* cos *v* / *a*

*y* = *r* sin *v*

*z* = -*h* cos *u* + *r* (cos 2*u* - cos *u*) cos *v* / *a*