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 justL / 2
)
Is there a way to calculate the bounds (top-left, top-right, bottom-right, and bottom-left) coordinates of the red square?
Best Answer
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)$.