# How to calculate a bounding box of a circle?

I'm writing a program in C++ to calculate the boundary box of a circle. The user provides me with a coordinate point (10, -5) and a radius of 23. I'm not very good at geometry and I need help in calculating the bounding box of this circle. How would I calculate this?

• What do you mean by bounding box? The square in which the circle is inscribed? What do you mean by "calculate" it? Do you want the equation? An array of points? Is the user provided coordinate point the center of the circle? Note that if you want a code specific answer stackoverflow might be a better place to ask. – Quantaliinuxite Jul 16 '17 at 22:01
• I'm not looking for code specific answers. Yes the points represents the centre of the circle. en.wikipedia.org/wiki/Minimum_bounding_box – ekeith Jul 16 '17 at 22:05

By bounding box I'm assuming you mean the box (square) in which the circle is inscribed, like in this picture:

Notice that the radius of the circle is exactly half the length of a side of the square.

So if the center of the circle is $(10,-5)$ and the radius of the circle is $23$, and if we're assuming a standard coordinate system ($y$-values increase in the up direction and $x$-values increase in the right direction), then the corners of the box are located at the following points:

\begin{align*} \text{upper left corner} &= (10-23, -5+23)\\ &= (-13, 18)\\[0.3cm] \text{upper right corner} &= (10+23, -5+23)\\ &= (33, 18)\\[0.3cm] \text{lower right corner} &= (10+23, -5-23)\\ &= (33, -28)\\[0.3cm] \text{lower left corner} &= (10-23, -5-23)\\ &= (-13, -28) \end{align*}

• Thanks, was able to translate this to my code – ekeith Jul 16 '17 at 22:26

Let us assume that the bounding box' sides are parallel to the coordinate axes. Then you just need to go 23 steps in every direction, so you'd get the square with the points

$$(10+23,-5+23),(10+23,-5-23),(10-23,-5+23),(10-23,-5-23)$$

i.e.

$$(33,18),(33,-28),(-13,18),(-13,-28)$$