What started out as an innocent question meant to poke me became an interesting math problem to ponder. You might want to read the original question and the answers presented. The final question was, can a square be described in any rotational orientation (based on the 2D Cartesian plane) with just 1 equation?

The answer is a resounding YES.

Meet Roie, who proposed this solution:

maximum {|r cos(theta-theta_0)|,|r sin(theta-theta_0)|} = c

This is basically modified from the max-abs solution by Mike Anderson:

max(abs(x),abs(y)) = c

You move from Cartesian coordinates to polar coordinates. Once you’re in polar plane, you can rotate by changing one variable (the angle). I actually wrote something about converting between Cartesian and polar coordinates for the use of image rotations. I can’t believe I forgot about that…

Roie also gave sample (GNU Octave or MATLAB) code:

theta0 = 0.5; x = ones(201,1) * (-10:0.1:10); y = x’; z = max(abs(sqrt(x.^2+y.^2) .* cos(atan(y./x)-theta0)),abs(sqrt(x.^2+y.^2) .* sin(atan(y./x)-theta0))); contour(z) axis square

Unfortunately, I am unable to verify that. Fortunately, Cees Meijer confirmed it for me. He introduced me to FreeMat, a free open source software that works like MATLAB. Unfortunately, I cannot install the Windows version because I need an x64 executable (I’m on Windows 7 64-bit), and FreeMat currently only has x86 version (32-bit).

Oh well, if it works, then I can finally do matrix multiplications in one line of code. So there, Will.