Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The box that an ellipse fits is easily calculated if there are no rotation, or if the rotation is ${x*90^o}$ (where x is an integer) is easy.

For a (major radius) and b (minor radius), it is :

Xmax = a
Ymax = b

or it is :

Xmax = b
Ymax = a

But how to do it in a general case, when the rotation angle is not a multiple of 90 degrees?

The limits to ellipse are like on the next image:
ellipse box

I am given all ellipse's parameter (as described in wiki) :

  1. ellipses formula:
    $x_{0}=a\cdot \cos (\varphi )$
    $y_{0}=b\cdot \sin (\varphi )$
    • where: a=major radius, b=minor radius, $\varphi \in [0,\pi ]$
  2. rotation formula:
    $x_{1}=x_{0}\cdot \cos (\Theta )-y_{0}\cdot \sin (\Theta )$
    $y_{1}=x_{0}\cdot \sin (\Theta )+y_{0}\cdot \cos (\Theta )$
    • where $\Theta$=ellipse's rotation

All parameters (a, b and $\Theta$) are known.

If you like you can also use the canonical form for ellipse: $\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$

share|cite|improve this question
What exactly are you given? E.g. do you have the equation for the rotated ellipse? – Quinn Culver Dec 13 '11 at 15:58
@QuinnCulver I added equations. Hope it is enough. btw I am looking for any kind of help on how to find the solution (I thought I finished with math 10 years ago ;) – BЈовић Dec 13 '11 at 20:33
My solution to a related question: (You can stop reading when you get to "$x_\star$" and "$y_\star$".) – Blue Dec 14 '11 at 2:13
up vote 5 down vote accepted

The previous answerer had the right idea, but the wrong execution. We have, for the rotated ellipse


the following expression for the derivative:

$$\frac{\mathrm dy}{\mathrm dx}=-\frac{a^2 x\,\sin^2\theta+y(a-b)(a+b)\sin\,\theta \cos\,\theta+b^2 x\,\cos^2\theta}{a^2 y\,\cos^2\theta+x(a-b)(a+b)\sin\,\theta \cos\,\theta+b^2 y\,\sin^2\theta}$$

We can separate the numerator and denominator of this expression, and equate any of the two to zero, and then solve as a simultaneous equation with the equation of the ellipse. (Zero numerator corresponds to horizontal tangents, and zero denominator corresponds to vertical tangents.)

After much algebra and tears, we find that the required limits are $x=\pm\sqrt{a^2\cos^2\theta+b^2\sin^2\theta}$ and $y=\pm\sqrt{a^2\sin^2\theta+b^2\cos^2\theta}$.

This could also have been done starting from the parametric equations; for that route, one will need to use the Weierstrass substitution so that one has the rational parametrization of the ellipse, and the problem is reduced again to the solution of algebraic equations.

Here is a Mathematica demonstration:

With[{a = Sqrt[2], b = 1, th = Pi/6}, 
 Block[{xa = Sqrt[a^2 Cos[th]^2 + b^2 Sin[th]^2], 
        ya = Sqrt[a^2 Sin[th]^2 + b^2 Cos[th]^2]}, 
         RotationMatrix[th].{a Cos[u], b Sin[u]}, {u, 0, 2 Pi}, 
         Epilog -> {AbsoluteThickness[4], 
         Line[{{-xa, -ya}, {xa, -ya}, {xa, ya}, {-xa, ya}, {-xa, -ya}}]}

ellipse in rectangle

share|cite|improve this answer

You don't need calculus here, just a little geometry.

Let $c$ be the (positive) $x$-coordinate of the vertical tangent, and let $d$ be the (positive) $y$-coordinate where the rotated ellipse meets the $y$-axis. Apply a vertical shear transformation, of the form $(x,y) \mapsto (x,y+ux)$, to transform the rotated ellipse into an ellipse with horizontal major axis $c$ and vertical minor axis $d$. This transformation is area-preserving, so $\pi cd = \pi ab$. Thus $c = ab/d$.

To find $d$, take the equation of the rotated ellipse (filched from J.M.'s answer):


and set $x = 0$:



$$\frac{d^2}{a^2b^2}(b^2\sin^2\theta+a^2\cos^2\theta) = 1$$


$$c = \frac{ab}{d} = \sqrt{b^2\sin^2\theta+a^2\cos^2\theta}$$

Similarly, using a horizontal shear transformation, the $y$-coordinate of the horizontal tangent is $\sqrt{a^2\sin^2\theta+b^2\cos^2\theta}$.

share|cite|improve this answer
"You don't need calculus here, just a little geometry." - I agree (+1), but I felt like nuking mosquitoes today... :) – J. M. Dec 14 '11 at 4:15

Let the equation of the ellipse be $\frac{X^2}{a^2}+\frac{Y^2}{b^2}=1$ in the rotated frame. The equation of tangent at parametric coordinate $\alpha$ becomes after rotation to the original frame $$ x\left(\cos\theta \cos\alpha/a+\sin\theta\sin\alpha/b\right)+y\left(\cos\theta \sin\alpha/a-\sin\theta\cos\alpha/b\right)=1$$ We need the tangents with slope 0 and inf. This gives the required lines as $$x=\frac{ab}{a\sin\theta\sin\phi+b\cos\theta\cos\phi}$$ and $$y=\frac{ab}{b\sin\theta\sin\phi+a\cos\theta\cos\phi}$$ where $\tan\phi=\frac ab\tan\theta$.

share|cite|improve this answer
This seems to have the wrong behaviour in the case $\theta=\pi/4$. In that case, we should have $x=y$, but setting them equal yields $(a-b)(\sin\phi-\cos\phi)=0$, which doesn't hold for $a\ne b$. – joriki Dec 13 '11 at 17:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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