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.
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.