# Knot Family

Curve · (x, y, z) = f(u, t)

`((2 + cos(q · u)) · cos(p · u),  sin(q · u),  (2 + cos(q · u)) · sin(p · u))`

[Open in the app](https://www.wavelace.com/app#p=138) · [This page](https://www.wavelace.com/presets/knot-family)

### What it draws

Read `2 + cos(q · u)` as a distance from the vertical axis: the cosine runs between `−1` and `1`, so the distance runs between `1` and `3`. The `cos(p · u)` and `sin(p · u)` it multiplies put the point at that distance and at the angle `p · u` around the axis. The second expression, `sin(q · u)`, is the height, and it stays between `−1` and `1`.

Height and distance are driven by the same `q · u`, so the point never leaves a torus: centre circle of radius `2` lying flat, tube of radius `1`, axis vertical. The angle around the axis is `p · u` and the angle around the tube is `q · u`, so over one turn of `u` the strand goes `p` times around the axis and `q` times around the tube. Nothing here depends on `t`, and the figure sits still.

### Knot, retrace, or open arc

A strand winding that way is the `(p, q)` torus knot, and the two sliders choose which one. Three things can happen. When `p` and `q` are whole numbers sharing no factor, the strand closes into one knot. From `Top` it then crosses itself `q · (p − 1)` times: `8` at the opening pair, `3` at `(2, 3)`, `5` at `(2, 5)`, `12` at `(7, 2)`. Swapping the two gives the same knot back, so that last picture is a more tangled drawing of a knot that needs only seven crossings.

When the two share a factor the strand closes early and then goes round again over its own path. At `(3, 3)` one loop is drawn over and over, and nothing is added after the first thirtieth of `u`.

When either slider leaves the whole numbers the strand needs more of `u` before its ends can meet. `Turns of u` opens at `10` to give it that: every stop of the two sliders is a whole number of tenths, so ten turns close every pair the sliders can reach. A whole coprime pair is simply drawn ten times over.

### Try

- Set `p` to 2 and `q` to 3: the trefoil, the simplest knot there is, and the same knot the preset Torus Knot ties on a slightly wider ring.
- Drag `q` to 5, leaving `p` at 3: the pair is coprime again and the count from above rises to 10.
- Drag `q` to 3 instead: now both are 3, and the strand is one loop traced over and over in place.
- Drag `p` to 3.5: ten turns still close it. Lower `Turns of u` to 1 and the same strand stops `6` short of its own start, the full width of the figure.
- Press `Top`: looking down the axis, the crossings sit in a ring between the tube's inner and outer edges.

### Read more

- [Torus knot](https://en.wikipedia.org/wiki/Torus_knot)
- [Trefoil knot](https://en.wikipedia.org/wiki/Trefoil_knot)
- [Coprime integers](https://en.wikipedia.org/wiki/Coprime_integers)
- [Knot theory](https://en.wikipedia.org/wiki/Knot_theory)
