I was trying to work out a single portion of a curve necessary for a stable square wheel. I was trying to do this with trigonometry only, which I wasn’t sure how possible this was to begin with, but I believe I found a curve that works. For a square of side length “s”, the following expression should keep the center of the square at a constant height and thus be a “road” for a square wheel:
$\frac{s\sqrt{2}}{2}(1-\frac{1}{\sin{(\frac{x\sqrt{2}}{s})}+\cos{(\frac{x\sqrt{2}}{s})}})$
For
$0\leq x\leq \frac{s\pi \sqrt{2}}{4}$
Which represents the curve for a quarter turn of the square. I calculated the maximum distance from the center of the square and the perimeter. I then calculated the distance between the center and all other points in the form of a function in polar form, and then used the curve to keep the total distance from the surface to the center constant for all angles within a quarter turn (since it will repeat itself after that point). Can someone verify if this curve will work?