Polygonometry

SquesmosPolygonometry
← Library

How polygonometry works

Walk a distance s around a regular n-gon inscribed in the unit circle. Each side has length L = 2 sin(π/n), so you're on side k = ⌊s/L⌋, which faces the angle φ = (2k+1)π/n. Then:
sine(s) = cos(π/n)·sin φ + (s − (k+½)L)·cos φ
cosine(s) = cos(π/n)·cos φ − (s − (k+½)L)·sin φ
The period is the perimeter, 2n·sin(π/n), which approaches 2π as n → ∞ (and the functions become plain sine and cosine). Instead of sin² + cos² = 1, the identity is "you're on the polygon": on each side, cosine·cos φ + sine·sin φ = cos(π/n). The slopes are cos φ and −sin φ, so the derivative of each sine is a staircase cosine.
The square is squine's home turf, so it uses the Squigulator's squine functions at p = ∞: sides at x, y = ±1, starting mid-side, period 8.
The squircle |x|ᵖ + |y|ᵖ = 1 is where Squesmos starts: squine and cosquine are the y and x of a point that has walked a distance s round it, so their period is its perimeter. p = 2 is the circle (plain sine and cosine), p = 4 the classic squircle, and as p grows it becomes the square.
Every one of these also works in the Squigulator: type trine(x), pentine x, or polysine(x, 12).