Question

I have a circle, say radius of 10, and I can find the outer bounding rect easy enough since its width and height is equal to the radius, but what I need is the inner bounding rect. Does anyone know how to calculate the difference in size from the outer and inner bounding rectangles of a circle?

Here's an image to illustrate what I'm talking about. The red rectangle is the outer bounding box of the circle, which I know. The yellow rectangle is the inner bounding rectangle of the circle, which I need to find the difference in size from the outer rectangle.

circle example

My first guess to find the difference is to find one of the four points of the inner rectangle by finding that point along the circumference of the circle, each point being at a 45 degree offsets, and then just find the different from that point and the related point in the larger rect.

EDIT: Based off of the solution given by Steve B. I've come up with the algorithm to get what I want which is the following:

r*2 - sqrt(2)*r
Was it helpful?

Solution

If the radius is r, the outer rectangle size will be r*2.

The inner rectangle will have size equals to 2*sqrt(2*r).

So the diff will be equals to 2*(r-sqrt(2*r^2)).

OTHER TIPS

You know the size of the radius and you have a triangle with a corner of 90 degrees with one point as the center of your circle and another two as two corners of your inner square.

Now if you know two sides of a triangle you can use Pythagoras:

x^2 = a^2 + b^2
    = 2* r^2

So

x = sqrt(2 * r^2)

With r the radius of the circle, x the side of the square.

It's simple geometry: Outer rectangle has length of edge equal to 2*R, inner - diagonal equal to 2*R. So the edge of inner rectangle is equal to sqrt(2)*R. The ratio of edges of outer rectangle divided by inner is obviously sqrt(2).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top