4
$\begingroup$

I'm trying to derive a formula to determine a tight bounding box for an ellipse. This is trivial for non-rotated ellipses, but I'm having trouble figuring out how to compute bounds for ellipses that have been rotated about their center.

Consider an ellipse $E$ centered at the origin with $x$ and $y$ radii $r_x$ and $r_y$ respectively. Then a point on $E$ is given by the parametric coordinate pair $\left[\begin{matrix}r_x \cos t \\ r_y \sin t\end{matrix}\right]$ for $t \in [0, 2\pi]$.

Suppose we rotate $E$ about the origin by $\theta$ radians. Then a point on $E$ has the coordinates $$\left[ \begin{matrix} x(t) \\ y(t) \end{matrix} \right] = \left[\begin{matrix}r_x \cos \theta \cos t - r_y \sin \theta \sin t \\ r_x \sin \theta \cos t + r_y \cos \theta \sin t \end{matrix}\right]$$

My approach to determine extrema was to consider each coordinate separately, take the derivative and set it equal to zero. For instance, we have $$x'(t) = -r_x \cos \theta \sin t - r_y \sin \theta \cos t$$ and setting $x'(t) = 0$ yields:

$$ \begin{align} -r_x \cos \theta \sin t - r_y \sin \theta \cos t &= 0 \\ -r_x \cos \theta \sin t &= r_y \sin \theta \cos t \\ \tan t &= -\frac{r_y \sin \theta}{r_x \cos \theta} \end{align} $$

I don't know how to go from this equation to the actual extreme values of $x$ for the rotated ellipse. I'm assuming it's something easy that I've just forgotten how to do.

Edit: I'm looking for tight axis-aligned bounds. Rotating the bounds of a non-rotated ellipse and then computing axis-aligned bounds of the rotated bounding box doesn't result in tight bounds. Here is a diagram to illustrate:

enter image description here

$\endgroup$
  • $\begingroup$ are there any restrictions on the bounding box? couldn't you just rotate the bounding box through the same angle? $\endgroup$ – Winston Aug 11 '16 at 19:44
  • $\begingroup$ if the bounding box needs to remain aligned with the axes, then you can maximize/minimize x(t) by solving for t in the tan(t) equation you have above (note there are infinite solutions) and plugging back in for x(t) (only two unique solutions). Then maximize/minimize y(t) similarly. $\endgroup$ – Winston Aug 11 '16 at 19:48
4
$\begingroup$

You're basically done: all you need to do is solve for your values of $t$, and substitute them into your $x(t)$ to obtain your extreme $x$ values:

$$t = \tan^{-1} \left(-\frac{r_y \sin \theta}{r_x \cos \theta}\right)$$

However, $\tan^{-1}$ has an infinite number of solutions of the form $t + \pi n$, for $n \in \mathbb{Z}$. This set of solutions can be divided into two sets: $A$, which contains values of the form $t + 2 \pi n$ and $B$, which contains values of the form $t + \pi + 2 \pi n$.

The only part you need to be careful of is to take one value of each of $A$ and $B$. One of these two sets of solutions will correspond to the lower extreme, and the other will correspond to the upper extreme.

If you want to know which set of values of $t$ corresponds to the minimum or maximum, you could use the second derivative test to find out.

$\endgroup$
  • $\begingroup$ I feel a little silly for asking, but how do you solve for values of $t \in [0, 2\pi]$ in your equation with arcsine? $\endgroup$ – tdenniston Aug 11 '16 at 22:28
  • $\begingroup$ Did you mean arctan? By convention, the range of $\tan^{-1}$ is $[-\pi / 2, \pi / 2]$, so upon computing $t$, you will have $t$ and $t + \pi$ as your two solutions (using the fact that $\tan(\alpha + \pi) = \tan(\alpha)$). Upon further consideration, I don't actually think it's necessary for you to restrict the values of $t$ to be within $[0, 2\pi)$, since $x(t + 2\pi) = x(t)$, and similar for $y(t)$. $\endgroup$ – theyaoster Aug 11 '16 at 23:30
  • $\begingroup$ Thanks! Got it working. For future readers, one can pick any two values for $n$ in $t+\pi n$ so long as $|n_1 - n_2| = 1$. $\endgroup$ – tdenniston Aug 12 '16 at 13:53
1
$\begingroup$

By $$A\cos t+B\sin t= \sqrt{A^2+B^2} \sin (t+\phi)$$

The dimensions of the rectangle are $$2\sqrt{r_x^2\cos^2 \theta+r_y^2\sin^2 \theta} \times 2\sqrt{r_x^2\sin^2 \theta+r_y^2\cos^2 \theta}$$

See the animation below:

enter image description here

$\endgroup$
  • $\begingroup$ very nice animation, how did you make it? $\endgroup$ – samjoe May 23 '18 at 14:11
  • $\begingroup$ Geogebra which is freeware. You may download here. $\endgroup$ – Ng Chung Tak May 23 '18 at 14:13
0
$\begingroup$

An alternative approach would be to consider the ellipse as fixed, and rotate the rectangle clockwise by angle $\theta$ so that the sides are tangential to the ellipse.

Let $m=\tan\theta$ so that the equation of one of the sides of the rectangle is $$y=-mx+c_1$$

Let the equation of a neighbouring side be $$y=\frac xm+c_2$$

Using the standard formula for the distance of a point to a line, considering the distances from the origin, the area of the bounding rectangle is $$4\times\frac{c_1}{\sqrt{1+m^2}}\times\frac{c_2}{\sqrt{1+\frac{1}{m^2}}}=\frac{4mc_1c_2}{1+m^2}$$

Now considering the standard ellipse $$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$$

The first line is tangent to the ellipse provided that, when solved simultaneously with the ellipse, the resulting quadratic has double roots.

After a couple of lines of algebra, we arrive at the condition $$a^2m^2=c_1^2-b^2\Rightarrow c_1=\sqrt{a^2m^2+b^2}$$

By similar argument we likewise obtain $$c_2=\sqrt{\frac{a^2}{m^2}+b^2}$$

Substituting these into the above expression for the area of the bounding rectangle, we end up with the formula$$\frac{4\sqrt{a^2m^2+b^2}\sqrt{a^2+m^2b^2}}{ 1+m^2}$$

$\endgroup$
  • $\begingroup$ I'm looking for tight axis-aligned bounds, and unfortunately this approach (which I tried first) does not result in tight bounds. I should have clarified that in my question. $\endgroup$ – tdenniston Aug 11 '16 at 22:27
  • $\begingroup$ Can you clarify what you mean by " tight axis aligned bounds"? The dimensions of the bounding rectangle are clear from my answer. $\endgroup$ – David Quinn Aug 11 '16 at 22:39
  • $\begingroup$ The rotated bounding rectangle (such that the sides are tangential to the rotated ellipse) isn't axis aligned, meaning the sides of the rectangle are not parallel to the axes. So the rotated bounds are indeed tight, but not axis aligned. $\endgroup$ – tdenniston Aug 11 '16 at 22:41
  • $\begingroup$ All you need are the perpendicular distances from the centre of the rectangle (and the ellipse) to the edges of the rectangle. These are the axis aligned distances you are looking for. The process of rotating the rectangle rather than the ellipse is equivalent to rotating the ellipse and keeping the rectangle aligned to the original axes. $\endgroup$ – David Quinn Aug 11 '16 at 22:47
  • $\begingroup$ I don't quite understand how the perpendicular (I'm assuming perpendicular to the axes?) distances from the center of the ellipse to the edges of the rotated rectangle can give the bounds of the rotated ellipse. $\endgroup$ – tdenniston Aug 11 '16 at 22:56

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.