Find ellipse rotation angle and minor semi-axis by two points

conic sectionscoordinate systemsrotationstrigonometry

Given two points with coordinates, and major semi-axis (a), I have to draw an ellipse (with the center of (0, 0)), which intersects with these points.

So I have to find minor semi-axis (b), and ellipse rotation angle.

There is an equation of rotated ellipse:

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

I tried to make a system of equations, but still can't figure out how to solve my problem.

Edit: It looks like my problem, that I described above, can have more than one solutions.

What I need initially is to draw a curve like on Google Earth "measure distance" feature:

enter image description here

So I try to calculate an ellipse, which intersects two points, and has center in the (0, 0) point. But I'm not sure this is the right decision.

How can I achieve this?

Best Answer

The equation of the ellipse, or in general the conic, that is centered at the origin is

$ r^T Q r = 1 $

where $r =[x,y]^T$ and

$Q = \begin{bmatrix} Q_{11} && Q_{12} \\ Q_{12} && Q_{22} \end{bmatrix} $

Since we're given two points then plugging these into the equation of the conic, we have the following linear equations in the elements of $Q$

$ Q_{11} x_1^2 + Q_{22} y_1^2 + 2 Q_{12} x_1 y_1 = 1 $

$ Q_{11} x_2^2 + Q_{22} y_2^2 + 2 Q_{12} x_2 y_2 = 1 $

We need a third equation, and this comes from the fact that

$ Q = R D R^T $

Since $R$ is a rotation matrix, then

$ \det(Q) = \det(D) = \dfrac{1}{a^2 b^2} $

and

$\text{Trace}(Q) = \text{Trace}(D) = \dfrac{1}{a^2} + \dfrac{1}{b^2} $

From the two above equations, we have our third equation relative the entries of matrix $Q$, which is

$ \dfrac{1}{b^2} = a^2 (Q_{11} Q_{22} - Q_{12}^2 ) = Q_{11} + Q_{22} - \dfrac{1}{a^2} $

Where the third equation is the equality on the right of this last equation.

Now we have a system of 2 linear equations, and 1 quadratic equation in the entries of matrix $Q$. And these can be solved without much difficulty, because of the fact that we have two linear equations, which means that we can solve for $Q_{11}, Q_{22}$ in terms of $Q_{12}$, and then plug these two expressions into the third equation, which will give us a quadratic equation in one variable only which is $Q_{12}$. Solving for $Q_{12}$ will generate two possible values, and by back substitution, we generate $Q_{11}$ and $Q_{22} $.

Having found two possible values for the matrix $Q$ we can immediately find $b$ from the above equations. To find $\theta$ we need to diagonalize $Q$ into the form $R D R^T$. The matrix $R$ has the form

$ R = \begin{bmatrix} \cos \theta && - \sin \theta \\ \sin \theta && \cos \theta \end{bmatrix} $

where matrix $D$ must be ordered as follows

$ D = \begin{bmatrix} \dfrac{1}{a^2} && 0 \\ 0 && \dfrac{1}{b^2} \end{bmatrix}$

As a numerical example, suppose $(x_1, y_1) = (2, 3)$ , $(x_2, y_2) = (-2, 1) $ and $a = 4$, then there will the following two ellipses as solutions.

enter image description here enter image description here

If we use the same two points, but make $a = 1$, then there will be two solutions that are hyperbolas.

enter image description here enter image description here