TITLE: How do I rotate a square around a circle?
QUESTION [39 upvotes]: I have

a circle of radius r
a square of length l

The centre of the square is currently rotating around the circle in a path described by a circle of radius $(r + \frac{l}{2})$

However, the square overlaps the circle at e.g. 45°. I do not want the square to overlap with the circle at all, and still smoothly move around the circle. The square must not rotate, and should remain in contact with the circle i.e. the distance of the square from the circle should fluctuate as the square moves around the circle.
Is there a formula or algorithm for the path of the square?
[edit]
Thanks for all your help! I've implemented the movement based on Yves solution with help from Izaak's source code:

I drew a diagram to help me visualise the movement as well (the square moves along the red track):

REPLY [7 votes]: At first it  appears that the inner vertex of the square is a circle of radius $r$ and outer vertex goes on circle radius $ r+ \sqrt2 l $.
However the constraint of parallel displacement of squares forces the squares to move horizontally or vertically maintaining sliding contact at four points $$(r,0), (0,r),(-r,0), (0,-r) $$  with square side sliding on circle radius $a$ at the  above points. It also defines an outer square envelope of side $(r+l)$ serving as outer boundary.
A rough sketch (sorry about the hand drawn Paint diagram) can indicate what is happening at outer boundary. 
If $\tan β=\dfrac{l}{l+r}$ then the eight demarcation of change over polar angles to flat square boundary are given by:
$$ θ= β, π/2-β,π/2+β, π-β, π+β, 3π/2-β, 3π/2+β,-β$$

Mathematica has RegionPlot command defining swept area:
r=a; a = 2; l = 1; RegionPlot[{x^2 + y^2 > a^2, x^2 + y^2 < (a + Sqrt[2] l)^2, Abs[x] 
< a + l, Abs[y] < a + l}, {x, -4, 4}, {y, -4, 4} ]