Question: I'm working on a program where I need to draw an arc in a rectangle fulfills these requirements:

1) The arc must be part of a perfect circle (not the band!), must not be oval  

2) The arc intersects the rectangle at the bottom left and bottom right corners  

3) The height of the arc does not exceed the height of the rectangle  

4) If the arc were assumed to be part of a circle, what the circle's center point would be

The requirements are such as many drawing libraries use a center point to calculate how to draw the arc accurately. The only information that we can use as input is the width and height of the rectangle, and the required output would be the center point of the circle and the radius. 

The image below shows an example - the input box, and the output circle.

![image](https://i.imgbox.com/2vsUZuwn.jpg)

I could write a brute force method to solve this, but I'd like something more elegant. I have found many sites which have answers like this that use a parabolic formula with width and height, but in this case the height (of the arc) is not definite- if, for example, the rectangle were very tall, the arc would only use space at the bottom of the rect.
If the rectangle were perfectly square, or the height of the rect was larger than the width, the formula would be easy-
(using a coordinate system where 0,0 is the bottom left corner)  

circle.centerPoint = (rect.width / 2, 0);  

circle.radius = (rect.width / 2);
But as the rect gets longer, the center point needs to drop and the radius needs to get larger.
I feel that this could be really easily figure out, but I just don't have the mathematical background to handle it. Is there a formula out there to solve this?

Disclaimer: I am bad at math, and never took a calculus class. Please keep answers simple.

Answer: 
One of my colleagues found me the answer pretty quickly, which I must say makes me rather ashamed.  

<http://www.mathopenref.com/arcradius.html>

R = H/2 + (W\*W / 8H)

So if W = 18 and H = 6,

R = 6/2 + (18 \* 18 / 8 \* 6)  

R = 3 + (324 / 48)  

R = 3 + 6.75  

R = 9.75

finding the centerpoint is then easy enough ( don't know why I listed it as a required output, but still):
centerpoint = (W / 2), (H - R)  

centerpoint = (18 / 2), (6 - 9.75)  

centerpoint = 9, -3.75
Given the width $w$ and height $h$ of a rectangle, let's find the circle, in terms of its position $P$ and radius $r$, that fits your description and has its top at the very top of the rectangle (first assuming $h \leq w$). 

Let $A$ be the bottom right point of the rectangle. Let $B$ be the point in the middle top of the rectangle. There is an isosceles triangle $PAB$ with sides of length $PA = r$, $PB=r$, and $AB=\sqrt{h^2+\frac{w^2}{4}}$. Further, the two equal angles are given by atan$(\frac{w}{2h})$. This is enough to give you $r$, then $P$ is $r$ below $B$. 

Note that if $h > w$, then you have to return the result as if $h = w$.