Fun with Excel and mathematics
I wrote this algorithm some years ago for a pure mechanical machine I've designed. The objective was to convert the movement of the tip of an rotating arm into a square output trajectory, while the opposite end of the arm is attached to a rotating shaft.
In the video below, there is a cell named "Crank arm ratio" and when set to the value 3 the output graph forms a square. Entering other values (in this demo from 0 to 20) shows interesting patterns developing.