$$z(x) = 2 \sin\left(\frac{\pi}{n}\right) \int_0^x e^{\left( i \frac{2\pi}{n} \sum_{k=1}^n \frac{1}{1 + e^{-(y-k)\theta}} \right)}\,dy$$

↑ If you graph that in polar coordinates from $x = 0$ to $x = n$, you get a regular n-gon.
The larger $\theta$ is, the sharper the edges are.

Controls

Credit to @math.rad on TikTok, who made a really nice 17 minute (😮) video about this function ( though I added the 2sin part).
I found this idea entirely from them and am just expanding on their explanation.

Source on GitHub  ·  Try it with stars →  ·  gear →

Geometry derivation