# Pintograph (revisited) - pretty patterns with mathematics

Geometric patterns are fun. In this post, I’m going to showcase a particular method of generating such patterns, named pintograph as coined by the daughter of Fran McConville. It is, at its simplest, two rods connected at one end to draw a line with a pen, and other ends connected to rotating circles. However, its mathematical definition is a bit more involved, yet required for simulating it accurately on a computer…

## Theory

In the event you have read a prior version of this post, you are correct noticing that the theory has been notably simplified. Other remastering has been done as well

Before we begin, we will make a couple of assumptions:

• Of two circles that define the pintograph, the origin of first will be at $(0,0)$, and second one exactly $d_{circle}$ away from the first one in horizontal direction. Origins are denoted as $P_{1}$, $P_{2}$
• Each circle will have a point on their perimeter, denoted $P_{r1}$ and $P_{r2}$. They are assumed to travel on the perimeter as a function of rotation given in radians, each with an individual time step value $t_{1}$, $t_{2}$
• We assume the circles will not overlap ($d_{circle} > r_{1}+r_{2}$), as otherwise it might not be possible to form a valid triangle $(P_{r1},P_{r2},P_{pen})$
• We seek to derive an equation for $P_{pen}$, which is where the line will be drawn at each time step from the previous point. As mentioned above, the points on circles and the pen are required to form a triangle. In addition to this, we require that segments $\overline{P_{r1}P_{pen}}$, $\overline{P_{r2}P_{pen}}$ are of equal length and constant length over time, hence forming an isosceles triangle of changing altitude. The altitude of said triangle is denoted as $h_{pen}$
• It would be possible to allow non-isosceles triangles, but this would add additional complexity diverting from the main point. Deriving the exact equations for such cases is left as an exercise to the reader

### Calculating $P_{r1}$, $P_{r2}$

First, we need to derive the exact coordinates of $P_{r1_{x,y}}$ and $P_{r2_{x,y}}$

\begin{align*} P_{r1} &= P_{1} + (r_{1} * \cos(t_{1}), r_{1} * \sin(t_{1})) & \\ P_{r1} &= (r_{1} * \cos(t_{1}), r_{1} * \sin(t_{1})) &P_{1} = (0,0) \end{align*}

and

\begin{align*} P_{r2} &= P_{2} + (r_{2} * \cos(t_{2}), r_{2} * \sin(t_{2})) & \\ P_{r2} &= (d_{circle} + r_{2} * \cos(t_{2}), r_{2} * \sin(t_{2})) &P_{2} = (d_{circle},0) \end{align*}

### Triangle

#### Determining $h_{pen}$

First, we’ll determine $\overrightarrow{P_{r1}P_{r2}}$:

\begin{align*} \overrightarrow{P_{r1}P_{r2}} &= P_{r2} - P_{r1} & \\ \overrightarrow{P_{r1}P_{r2}} &= (d_{circle} + r_{2} * \cos(t_{2}), r_{2} * \sin(t_{2})) - (r_{1} * \cos(t_{1}), r_{1} * \sin(t_{1})) & \text{substitution} \\ \overrightarrow{P_{r1}P_{r2}} &= (d_{circle} + r_{2} * \cos(t_{2}) - r_{1} * \cos(t_{1}), r_{2} * \sin(t_{2}) - r_{1} * \sin(t_{1})) & \\ \end{align*}

and magnitude for it

$|\overrightarrow{P_{r1}P_{r2}}| = \sqrt{(d_{circle} + r_{2} * \cos(t_{2}) - r_{1} * \cos(t_{1}))^{2}+(r_{2} * \sin(t_{2}) - r_{1} * \sin(t_{1}))^{2}}$

Knowing1 $h = \sqrt{b^{2}-\frac{1}{4}a^{2}}$ for isosceles triangles, we come to the conclusion:

$h_{pen} = \sqrt{(|\overline{P_{r1}P_{pen}}|)^{2} - \frac{1}{4}(|\overrightarrow{P_{r1}P_{r2}}|)^{2}}$

The equation would be far too long if written fully, so it will be omitted. Geometrically the result does make sense though - as sides are of constant length, longer distance between points on circles means smaller height.

### Determining $p_{pen}$

#### Midpoint of $\overrightarrow{P_{r1}P_{r2}}$

Let midpoint be $p_{mid}$

\begin{align*} p_{mid} &= \frac{p_{r1}+p_{r2}}{2} & \\ p_{mid} &= \frac{(r_{1} * \cos(t_{1}), r_{1} * \sin(t_{1}))+(d_{circle} + r_{2} * \cos(t_{2}), r_{2} * \sin(t_{2}))}{2} & \text{substitution} \\ p_{mid} &= (\frac{r_{1} * \cos(t_{1}) + d_{circle} + r_{2} * \cos(t_{2})}{2}, \frac{r_{1} * \sin(t_{1}) + r_{2} * \sin(t_{2})}{2}) \\ \end{align*}

#### Deriving $p_{pen}$

We now have sufficient information for the final equation:

\begin{align*} p_{pen} &= p_{mid} + h_{pen} * \hat{\overrightarrow{P_{r1}P_{r2}}}^{\perp} \\ \end{align*}

Knowing2 rotation by 90 degrees counter-clockwise is $(x,y) \rightarrow{} (-y, x)$ and that $\hat{V} = \frac{V}{\\|V\\|}$, deriving $\hat{\overrightarrow{P_{r1}P_{r2}}}^{\perp}$ is quite straightforward. It will be omitted for brevity.

## Practice

For convenience and demonstrating what you should be able to do with the given equations, here is an interactive model of a pintograph. Tinker with the settings and see what you achieve

For example, what happens if you have circles of same size, but different rotation speed? Same speed but different sizes? Or, same speed and sizes, but different directions? What happens when you adjust them whilst the plotter is drawing?

Set settings below, and press Start to start a rendering process. Press Stop to stop it; Reset will clear the canvas. D is fixed at 8, rods at 15 each