4

I originally asked this in an answer to the following question:

What is the equation of an ellipse that is not aligned with the axis?.

As I noted in the opening paragraph I DO NOT HAVE THE NECESSARY REPUTATION TO COMMENT YET. That was why I had to provide an answer rather than doing the very natural thing of commenting.

Two people: pjs36 and Ben S both advised asking a new question, even though I believe this is a duplicate of that question.

The problem is very simple: user1089161's answer is almost a perfect answer for the problem I'm trying to solve, except it is expressed in terms of the slope 's' along which the major axis lies. This means that if the major axis is parallel to the y axis, the answer becomes degenerate.

So how could that answer be expressed in terms of the angle by which the major axis has been rotated rather than the slope on which it lies?

3 Answers3

4

I recently was working on coming up with a formula for a catenary problem (more specifically dealing with the hyperbolic cosine) and the equation for a rotated ellipse was an integral (lol) part of my ultimate success with it. Here's the equation you're looking for:

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

This assumes no vertical or horizontal shifts. If those are necessary, substitute $(x-x_1)$ for $x$ and $(y-y_1)$ for $y$.

  • This is a good answer. Could you clarify what exactly $\theta$ means here? e.g. the angle between the ellipse's major axis and the x-axis? – Mobeus Zoom May 25 '20 at 20:03
1

Copy & paste from user1089161's answer mentioned for reference: $$\frac{((y - y_c) - s(x - x_c))^2}{m^2(1 + s^2)} + \frac{(s(y - y_c) + (x - x_c))^2}{M^2(1 + s^2)} = 1$$

Let use replace $s$ with $tan\theta=\frac{\sin\theta}{\cos\theta}$ to give:

$$\frac{((y - y_c) - \frac{\sin\theta}{\cos\theta}(x - x_c))^2}{m^2(1 + \left(\frac{\sin\theta}{\cos\theta}\right)^2)} + \frac{(\frac{\sin\theta}{\cos\theta}(y - y_c) + (x - x_c))^2}{M^2(1 + \left(\frac{\sin\theta}{\cos\theta}\right)^2)} = 1$$

Next multiple each fraction by $\frac{\cos^2\theta}{\cos^2\theta}$. Note the denominators then include a $\cos^2\theta+\sin^2\theta$ term which disappears.

$$\frac{(\cos\theta(y - y_c) - \sin\theta(x - x_c))^2}{m^2} + \frac{(\sin\theta(y - y_c) + \cos\theta(x - x_c))^2}{M^2} = 1$$

This answer can also be arrived at from Américo Tavares' comment to Henry's answer in the mentioned question. They use a matrices based approach. I don't know your background so you may not have yet covered matrices but an application of matrices is finding rotations/reflections/other transformations of 2D (or higher) shapes.

Ian Miller
  • 12,140
0

Maybe this isn’t the kind of answer you’re looking for, but a general conic in the plane has equation $$ Ax^2+Bxy+Cy^2+Dx+Ey+F=0\,, $$ and if the real locus is neither empty nor reduced to a single point, it should be an ellipse if and only if $B^2-4AC<0$.

EDIT (expansion):

The orientation of the conic is determined by the monomials of degree two only: that is, if two conics have the same values for $A$, $B$, and $C$, they have axes that are parallel. So we can concentrate on the associated binary quadratic form $Ax^2+Bxy+Cy^2$.

We want to rotate by an angle $\theta$ to get the axes of the conic parallel to the coordinate axes. This means making a substitution $x=cx'-sy'$, $y=sx'+cy'$, where I’m using the shorthand $c=\cos\theta$ and $s=\sin\theta$. When you make this substitution, you get a new quadratic form in $x'$ and $y'$, and you want to adjust $\theta$ so that the $x'y'$-term is zero. When you do the expansion and collect terms, you get for the coefficient of $x'y'$ the expression $$ -2csA+c^2B-s^2B+2csC\,. $$ Setting this equal to zero and putting the $cs$ terms on one side, the $B$ terms on the other, you get \begin{align} (c^2-s^2)B&=2cs(A-C)\\ B\cos(2\theta)&=(A-C)\sin(2\theta)\\ \tan(2\theta)&=\frac B{A-C}\,, \end{align} and I think that should do it, unless I rotated in the wrong direction, in which case you should replace $A-C$ in the final eqution by $C-A$.

Lubin
  • 65,209