Hypercycloid, hypocycloid, and more general version, the hypertrochoid and hypotrochoid, are curves of the locus of a point on a circle rolling on a bigger circle. Like many other locus problems, it is convenient to tackle it from parametric equations.

We go with the hypercycloid (aka epicycloid) first. Consider the image below from Wikipedia, we have a bigger circle of radius with centre fixed at the origin. The smaller, rolling circle of radius is rolling on the outside of the circle such that there is always a single point of intersection between the two circles. The locus of interest is drawn by point on the smaller circle while it rolls.

Observe that when the smaller circle is rolling, its centre always follows a circle of radius centred at the origin. Assume at the moment that the smaller circle rolled to the position such that its centre is at angle as illustrated, the length of arc it has rolled is . This is the same length measured on the big or small circle. Assume point is the point of contact of the two circle when . At the moment of an unspecified , the point is at the angle of relative to the point of contact of the two circle at the moment, or at the angle of relative to the axis (such angle is measured at the third quadrant).

Given that we have the coordinate of the centre of the smaller circle to be

and the coordinate of the point to be

and more generally, if point is on a circle of radius eccentric to the smaller circle, then the parametric formula of the locus of the hypertrochoid (aka epitrochoid) is:

The derivation is similar if the smaller circle is rolled on the inside of the bigger circle. Except that the angle of point relative to the axis when the centre of the smaller circle is at angle is (measured at the first quadrant), as now the point is on the clockwise side rather than counterclockwise side when the smaller circle rolled. So similarly, the parametric equation of hypocycloid is:

and the more general version, hypotrochoid, is:

In above, we added an angle to such that we allow a version rotated about the origin. The shape, however, should be just the same.

Now some code. I like the animated GIF on wikipedia page that shows how the locus is created as the parameter goes from 0 up to some big angle. Generating such animation is indeed not hard, as we already derived the coordinates and metrics of everything need to show. I will use Python, for its Pillow library is handy to create such pictures. And in addition to GIF, I can also generate animated image in Google’s WebP format. Here is the code (python 3.6+ required due to type hint syntax):

and this is the command to generate a hypercycloid:

```
python3 hypchoid.py -q 180 hyper.webp
```

and this is for a hypochoid:

```
python3 hypchoid.py -p 50 -o hypo.webp
```