Given the bounds of a rotated ellipse, can you find the semi-major and semi-minor axis?

862 Views Asked by At

Clarification: I am trying to find the semi-axes $(a,b)$ given the bounding rectangle's dimensions $(x,y)$. To constrain the problem, I am keeping $\theta$ the same as my original ellipse. The answer should be in terms of $(a,b) = f(\theta, width, height)$

I'm probably missing a fundamental step, but I have the equation to create the bounding box of a rotated ellipse working fine. I can see this by plotting it on a canvas. The challenge I'm facing is reversing the process. I'm trying to use the general equation of the ellipse. I have the following information:

  • Bounding rectangle of rotated ellipse (using deltaX and deltaY to eliminate translations)
  • Angle of rotation (degrees, up is 0)
  • Eccentricity of the ellipse

The problem I am trying to solve is resizing an ellipse so that it fits the new bounding box as the user drags the control points, so I have the original ellipse. Here is what I have:

$\theta = \frac{(angle + 90) \pi}{180}\\ x = rect.Width\\ y = rect.Height\\ e = \frac{SemiMajor}{SemiMinor}\\ a = SemiMajor\\ b = \frac{a}{e}$

General Equation of Ellipse:

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

Since I have all the angle and outer dimensions, I'm solving the top part of the equation to make things a bit easier:

$T_1 = x \cos{\theta} + y \sin{\theta}\\ T_2 = x sin{\theta} + y cos{\theta}$

Then I solve for $a$ (SemiMajor)

$\frac{T_1^2}{a^2} + \frac{T_2^2}{(\frac{a}{e})^2} = 1\\ \frac{T_1^2}{a^2} + \frac{T_2^2 e^2}{a^2} = 1\\ T_1^2 + T_2^2 e^2 = a^2\\ a = \sqrt{T_1^2 + T_2^2 e^2}\\ b = \frac{a}{e}$

The problem is that my SemiMajor is larger than my original SemiMajor even when giving it the same bounding box that it was derived from. There's probably something stupid and fundamental I'm missing.

1

There are 1 best solutions below

0
On

[N.B.: This is only a partial solution for the reason given at the end.]

If I understand the question correctly, given a rectangle aligned with the coordinate axes, you’d like to inscribe an ellipse in it that has a given inclination $\phi$. There are several constructions for ellipses inscribed in rectangles given at this web site. The Java applets there won’t run with modern security settings, but you should be able to get the gist of them without the demos. They’re pretty easy to cons up in something like GeoGebra if you’d like to see them in action.

The second construction—ellipse given its axes—looks like one that would suit your problem. I’ll repeat the construction here so that this answer’s self-contained:

  1. Choose a corner $C$ of the rectangle.
  2. Find the intersection $I$ of this corner’s angle bisector with the minor axis line. This angle bisector will of course be at an angle of $\pm\frac\pi4$, i.e., will have slope $\pm1$.
  3. Find the intersection $W$ of the perpendicular bisector of $\overline{CI}$ with the minor axis line. This perpendicular bisector will be at an angle $\mp\frac\pi4$, with a slope of $\mp1$.
  4. Find the intersection of the circle with center $W$ and radius $\overline{WI}$ with the major axis line. This gives you the foci $F$ and $F'$ of the inscribed ellipse.
  5. Project a focus onto one of the nearer sides of the rectangle. The distance from the center to this point is the ellipse’s semimajor axis length $a$.

Note that this construction only works if the axis lines intersect all four sides of the rectangle. If not, the foci end up outside of the rectangle and you end up with an hyperbola instead. I’m not sure that there is an ellipse with the given inclination that is tangent to all four sides in that case, so you’ll likely have to try something else. If the major axis line coincides with a diagonal of the rectangle, the constructed ellipse collapses to a line so you’ll have to handle that case, too.