Maths101 question – does anyone know how to calculate an ellipse (width/height) that will enclose a given rectangle. Obviously there is no single ellipse – I’m after an algorithm that will give me various width/height combinations – or perhaps the smallest area of ellipse? It’s for a GUI, so an aesthetically pleasing ratio of height/width is what I’m looking for.
Thanks in advance.
The equation for a ellipse centered in the origin is
Now if you want to enclose a rectangle of MxN with a eclipse you can move its center to the origin of coordinates. The top right coordinates are
(M/2,N/2), replacing in the ellipse equation you have a formula you can use to solve B given A (or A given B).If you have a rectangle of 4×2, the top-right coordinates are (2,1), replacing you have the
(2/A)^2 + (1/B)^2 = 1, then ifA=4solving for B givesB=1/sqrt(1-(1/2)^2).