How to calculate the bounds of a square within a circle with known radius? Given these information:



*

*Top-left coordinates of the green square, (0, 0)

*Center coordinates, (x, y)

*Length of the green square, L

*Radius of the blue circle, r (which basically just L / 2) 


Is there a way to calculate the bounds (top-left, top-right, bottom-right, and bottom-left) coordinates of the red square?
 A: The circle has a radius of $x$, which is also half the diagonal of the red square. So the red square has a side length of $2x/\sqrt{2}=L/\sqrt{2}$. That should be sufficient information to caclulate your bounds.

 The $x$- and $y$-coordinates of the corner points are both $x\pm x/\sqrt{2}$.

A: Consider the following picture.

Line segment $a$ has length $\frac{L}2$. Therefore, line segment $b$ also has length $\frac{L}2$ (they are both radii of the blue circle).
Therefore, in the triangle $bcd$ we see that $c$ and $d$ both have length $\frac{L}{2\sqrt{2}}$.
Now the center has coordinates $\left(\frac{L}2, \frac{L}2\right)$.
This means that the corner coordinates are $\left( \frac{L}2 \pm \frac{L}{2\sqrt{2}}, \frac{L}2 \pm \frac{L}{2\sqrt{2}}\right)$.
A: The top-left corner of the red square is a distance $L/2$ from the centre of the circle which is at $(-L/2,-L/2)$. Thus the top-left corner has coordinates $(a,a)$ which satisfy 
$$||(a,a)-(-L/2,-L/2)||=||(a+L/2,a+L/2)||=\frac{L}{2}$$
where $||\cdot||$ denotes the Euclidean distance.
Thus we need $$\left(a+\frac{L}{2}\right)^2+\left(a+\frac{L}{2}\right)^2=2\left(a+\frac{L}{2}\right)^2=\left(\frac{L}{2}\right)^2$$
so that  $$a=\left(1-\frac{1}{2\sqrt{2}}\right)L.$$
