Find a specific rectangle in an ellipse

808 Views Asked by At

For a software developpment, I need to find a rectangle that fits in an ellipse.

I have an outer rectangle (left, top, width and height) and a function that draws an ellipse in it. Now I need to know left, top, width and height of a rectangle that fits in this ellipse (to write some text in it) I'm aware that there are an infinity of possibilities, I think the best one would be the one in blue in the following picture : enter image description here

1

There are 1 best solutions below

0
On

Let $\dfrac{x²}{a²}+\dfrac{y²}{b²}=1$ be the equation of the ellipse.

The outer rectangle has lenght and height $2a$ and $2b$ respectively.

The inner rectangle upper right corner $A(x_A,y_A)$ is on the ellipse, hence $\dfrac{x_A^²}{a²}+\dfrac{y_A^²}{b²}=1$.

The two rectangle are of similar proportions, hence $\dfrac{x_A}{y_A}=\dfrac{a}{b}$.

By combining the two equations you get:

$x_A^2=\dfrac{a²}{2}$ and $y_A^²=\dfrac{b²}{2}$

EDIT: another demonstration relies on the square. Between the square inscribed in a circle and the one outside the same circle, there is a relation of $\sqrt{2}$ between the sides (easy to see when considering that the diagonal of one is the side of the other). Then, rectangles are homothetic from squares and the results holds.