3
$\begingroup$

I'm trying to find the ellipse that bounds a rectangle in a way that the "distance" between the rectangle and the ellipse is the same vertically and horizontally.

Here is an image to illustrate what I mean:

illustration

It's not perfectly drawn but the two "x" dimension need to be the same.

What I tried so far is:

The ellipse equation is $$\left(\frac{x}{a}\right)^2 + \left(\frac{y}{b}\right)^2 = 1$$

  • The "ellipse bounding the rectangle" constraint gives us $$\left(\frac{w}{a}\right)^2 + \left(\frac{h}{b}\right)^2 = 1$$
  • The "x dimension must be equal" constraint gives us $a-w = b-h$

So it's basically a $2$ equations system with $2$ unknowns.

But I got stuck at this point. If I do a substitution I have

  • $$a = b-h+w$$
  • $$\left(\frac{w}{b-h+w}\right)^2 + \left(\frac{y}{b}\right)^2 = 1$$

and I don't know how to solve it.

$\endgroup$
  • $\begingroup$ What do not you center everything (ellipse + rectangle) at (0,0) ? $\endgroup$ – Claude Leibovici Jan 1 '14 at 12:39
  • $\begingroup$ I think I did, didn't I? The illustration might be false though (in a way "a", "b", "w" and "h" might actually be "2a", "2b", "2w" and "2h"). But it doesn't change the problem much. $\endgroup$ – user1534422 Jan 1 '14 at 12:45
  • $\begingroup$ Are you looking for the smallest allipse or for any ellipse containing the rectangle ? Michael Albanese and I did not understand the same thing. Please clarify. $\endgroup$ – Claude Leibovici Jan 1 '14 at 13:12
  • $\begingroup$ I looking for the ellipse that goes through the rectangle edges. $\endgroup$ – user1534422 Jan 1 '14 at 13:40
  • $\begingroup$ Have you be able to continue with what I gave you as an answer ? $\endgroup$ – Claude Leibovici Jan 1 '14 at 13:45
1
$\begingroup$

If you centre the rectangle on the origin, then it has vertices at $(-\frac{w}{2}, -\frac{h}{2})$, $(\frac{w}{2}, -\frac{h}{2})$, $(\frac{w}{2}, \frac{h}{2}),$ and $(-\frac{w}{2}, \frac{h}{2})$.

An ellipse centred at the origin has equation $\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1$ where $a$ is the 'horizontal' radius, and $b$ is the 'vertical' radius (here I am taking $a$, $b$ positive). Then the ellipse you are looking for must satisfy

$$a-\frac{w}{2} = b - \frac{h}{2}$$

or equivalently

$$2a - w = 2b - h.$$

If $w$ and $h$ are given, this is one equation between the two unknowns $a$ and $b$. This corresponds to the fact that there is an infinite family of ellipses which satisfies the distance condition.

You need one more piece of information to uniquely determine the ellipse. For example, if you would like the ellipse to go through the vertices of the rectangle, then we must have

$$\frac{\left(\dfrac{w}{2}\right)^2}{a^2} + \frac{\left(\dfrac{h}{2}\right)^2}{b^2} = \frac{w^2}{(2a)^2} + \frac{h^2}{(2b)^2} = 1.$$

Rearranging $b$ for $a$ in the previous equation, we obtain $b = a + \frac{1}{2}(h-w)$. Substituting into the latter equation, we see that $a$ must satisfy

$$\frac{w^2}{(2a)^2} + \frac{h^2}{(2a + h - w)^2} = 1$$

which, when rearranged, is a quartic in $a$.

Note, if $h = w$ (i.e. the rectangle is a square), then $a = b = \frac{w}{2}\sqrt{2}$ so the ellipse is a circle with radius equal to the distance between the origin and a vertex of the square (as one would expect).

Example: If $h = 1$ and $w = 2$ we obtain

$$\frac{4}{(2a)^2} + \frac{1}{(2a-1)^2} = 1$$

which becomes

$$4a^4-4a^3-4a^2+4a-1=0.$$

This only has two real roots, but the only positive one is $a = 1.2908$. From the first equation, we then see that $b = 0.7908$.

The result can be seen below (made using WolframAlpha).

enter image description here

$\endgroup$
  • $\begingroup$ I thought that the OP was looking for the largest recatngle or the smallest ellipse. If this is not the case, you are right and .... I am wrong. Happy New Year !! $\endgroup$ – Claude Leibovici Jan 1 '14 at 13:09
  • $\begingroup$ So yeah... it's a quartic as I suspected :( Which means the solution is a monster :D I'm going to take a look to the heuristic since I going to use that in an IT project. $\endgroup$ – user1534422 Jan 1 '14 at 13:11
  • $\begingroup$ @ClaudeLeibovici: My interpretation was that the rectangle is given, and the ellipse is sought after. Hopefully the OP will be able to provide some clarification. $\endgroup$ – Michael Albanese Jan 1 '14 at 13:11
  • $\begingroup$ @user1534422: Unless you want a general formula, using a calculator to solve the resulting quartic should be sufficient. $\endgroup$ – Michael Albanese Jan 1 '14 at 13:12
  • $\begingroup$ If my approach is correct, there is no quartic but only quadratic. $\endgroup$ – Claude Leibovici Jan 1 '14 at 13:14
0
$\begingroup$

HINT

Let us put everything centered at (0,0) and since everything is symmetrical, we shall just look at the first quadrant.

So you look for a value of "x", smaller than "a", such that (a - x) be equal to (b - y). But you know that the upright corner of the rectangle is also along the ellipse. This means that

y = b Sqrt[1 - (x/a)^2].

Can you continue from here ?

Happy New Year

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.