# Equation of diagonal ellipse knowing 2 foci and eccentricity

I am trying to find the equation of a diagonal ellipse knowing the position of the two focus points and the eccentricity. Online I can only find the equation of the ellipse where the two foci are located on the same y axis value. Any idea on how to do this? Thank you.

• Find the equation of the ellipse in a more convenient coordinate system, and then rotate/scale the coordinates to make the foci end up where you want them. – hmakholm left over Monica Jun 27 '17 at 8:53

The ellipse with focal distance $2c$ and eccentricity $e$ has major axis $2a=2c/e$ and minor axis $2b=2c\sqrt{1/e^2-1}$.

Thus, if you have the focal distance you can write down an equation of an ellipse with the right size and shape: $$b^2x^2 + a^2y^2 = a^2b^2$$

Now to turn the ellipse counterclockwise by angle $\theta$, apply a rotation of the coordinate system: $$\begin{pmatrix}x\\y\end{pmatrix} \mapsto \begin{pmatrix} \cos(\theta)x + \sin(\theta)y \\ -\sin(\theta)x + \cos(\theta)y \end{pmatrix}$$ Stick that into our equation for the ellipse and we get $$b^2(\cos(\theta)x+\sin(\theta)y)^2 + a^2(\cos(\theta)y-\sin(\theta)x)^2 = a^2b^2$$ You can now calculate the sines and cosines and simplify to get the equation into the nice form $$Ax^2+Bxy+Cy^2 = a^2b^2$$

If your target ellipse is not centered at $(0,0)$, you can translate the equation by replacing $x\mapsto x-x_0$, $y\mapsto y-y_0$.

Of course you don't need to actually compute $\theta$ and trig functions if you have the coordinates of the foci, because then $\cos\theta$ is $\frac{(F_2-F_1)_x}{2c}$ and $\sin\theta=\frac{(F_2-F_1)_y}{2c}$.

• Thank you for your answer. I am trying to implement it in c++, but it really seems complicated. Is there any simpler way to find the intersection points between two ellipses? – Pino Jun 27 '17 at 10:51

Let $F_1, F_2$ be the two foci, $e$ be the eccentricity, and $P(x,y)$ be a general point.

Using the definition of an ellipse, we have $\dfrac ca=e$ where focal distance $c=\frac 12 F_1F_2$, and also

$$PF_1+PF_2=2a=\frac {F_1F_2}e$$

Expanding this should give the equation of the ellipse.

• This gives an unwieldy equation with square roots on the left-hand side, though -- whereas we know that every ellipse is the locus of solution to a quadratic equation in two variables. – hmakholm left over Monica Jun 27 '17 at 9:40

Hint:

Remember that the eccentricity is $e=\frac{c}{a}$, where $c$ is the distance of a focus from the center of the ellipse and $a$ is the major semiaxis of the ellipse.

So:

1) if you know the two foci $C_1$ and $C_2$, you can find the center $C$ of the ellipse (the midpoint of $C_1C_2$) and the value of $c$,

2) than, using te eccentricity, find $a$

3) remember that, by definition, the equation of an ellipse, for a point $X=(x,y)$ is $\overline {XC_1}+ \overline {XC_2}=2a$

Let $c$ be the half of the distance between two focii. Then major axis $a=\frac{c}{e}$, where $e$ is eccentricity. Minor axis $b=\sqrt{a^2-c^2}$

Find equations of major and minor axis.

$$\frac{y-y_1}{x-x_1}=\frac{y_2-y_1}{x_2-x_1}\space$$ and $$-2xx_1+x_1^2-2yy_1+y_1^2=-2xx_2+x_2^2-2yy_2+y_2^2$$

Read $\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$ as:- $$\frac{(Distance\space from\space minor\space axis)^2}{(Length\space of\space major\space axis)^2}+\frac{(Distance\space from\space major\space axis)^2}{(Length\space of\space minor\space axis)^2}=1$$

and apply!

NOTE : This is a property of any ellipse regardless of orientation and center. It can be proved from the defining property of an ellipse, and is another defining property of the same.

PROOF:- Let $P$ be apoint with distances $a-t$ and $a+t$ from focii, $x$ from minor axis, $y$ from major axis. Then:- $$(a+t)^2 = (x+c)^2+y^2\space and \space (a-t)^2 = (x-c)^2+y^2\space(Applying\space Pythagoras'\space theorem)$$ Eliminate $t$ to get $\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$

DEMO : here

• Are you sure that this equation works for diagonal ellipses as well? – Pino Jun 27 '17 at 9:18
• Yeah, this is a property of any ellipse. – Meet Taraviya Jun 27 '17 at 9:32
• but how should I change x^2 and y^2? Shouldn't I take into account the centre of the ellipse? – Pino Jun 27 '17 at 9:36
• What do you mean? You just to need to find the equation of axes. The center will be accounted by itself due to their intersection. – Meet Taraviya Jun 27 '17 at 9:45
• Here en.wikipedia.org/wiki/Ellipse#Equation_of_a_shifted_ellipse it is written that this formula only works when the axes are still parallel to the x- and y-axes. – Pino Jun 27 '17 at 9:49

One benefit of coordinate geometry is that it can eliminate detours that go via angles and trigonometric functions. This is an example.

Given an ellipse with eccentricity $\epsilon$ and foci $F_1=(x_1,y_1)$, $F_2=(x_2,y_2)$, then a straight line $T$ is tangent to the ellipse if and only if the product of the oriented distances of the foci to $T$ equals the square of the ellipse's minor semiaxis length $b$: $$(TF_1)\,(TF_2) = b^2$$ This allows us to immediately write down the coefficient matrix for the dual ellipse: $$N = \operatorname{symm}\begin{bmatrix}x_1\\y_1\\1\end{bmatrix} \begin{bmatrix}x_2\\y_2\\1\end{bmatrix}^\top - b^2\begin{bmatrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 0\end{bmatrix} = \begin{bmatrix} x_1 x_2 - b^2 & \frac{h}{2} & x_0 \\ \frac{h}{2} & y_1 y_2 - b^2 & y_0 \\ x_0 & y_0 & 1 \end{bmatrix}$$ where \begin{align} b^2 &= \frac{(x_1-x_2)^2+(y_1-y_2)^2}{4} \,\frac{1-\epsilon^2}{\epsilon^2} & x_0 &= \frac{x_1+x_2}{2} \\ h &= x_1y_2 + y_1x_2 & y_0 &= \frac{y_1+y_2}{2} \end{align} The adjugate matrix of $N$ gives the coefficient matrix of the ellipse's equation.