How to find an intersection point between a line and an ellipse, where the line passes from the center of the ellipse?

1.7k Views Asked by At

How to find an intersection point between a line and an ellipse, where the line passes from the center of the ellipse?

I know everything about the ellipse.

I know the angle $(\theta)$ (whose $\tan$ will be slope) and starting point of the line (where the starting point is the center of the ellipse).

Here are the equations which I'm trying to use: $$\frac{(x-x_{0})^2}{a^2} + \frac{(y-y_{0})^2}{b^2}$$ $$y = \tan(\theta) \cdot x + n$$ $$n = y_{0} - x_{0} \cdot \tan(\theta)$$

2

There are 2 best solutions below

8
On BEST ANSWER

First, I assume the ellipse you're using has a center at $(x_0,y_0)$, a width of $2a$ and a height of $2b$. If so, the entire equation then is

$$\frac{(x-x_{0})^2}{a^2} + \frac{(y-y_{0})^2}{b^2} = 1 \tag{1}\label{eq1}$$

You also give

$$y = \tan(\text{angle}) * x + n \tag{2}\label{eq2}$$ $$n = y_{0} - x_{0} * \tan(\text{angle}) \tag{3}\label{eq3}$$

Let $\alpha = \text{angle}$, then substitute \eqref{eq3} into \eqref{eq2}, rearrange and factor to get

$$y - y_0 = \left(x - x_0\right)\tan(\alpha) \tag{4}\label{eq4}$$

This equation indicates $\alpha$ is the angle, relative to the positive $x$-axis, of the line through the ellipse center.

At the intersection points (note there will be $2$ of them), the values of $x$ and $y$ will need to satisfy both \eqref{eq1} and \eqref{eq4} simultaneously. To determine their values, substitute \eqref{eq4} into \eqref{eq1} to get

\begin{align} 1 & = \frac{(x-x_{0})^2}{a^2} + \frac{\left((x-x_{0})\tan(\alpha)\right)^2}{b^2} \\ & = (x-x_{0})^2\left(\frac{1}{a^2} + \frac{\tan^2(\alpha)}{b^2}\right) \\ & = (x-x_{0})^2\left(\frac{b^2 + a^2\tan^2(\alpha)}{a^2 b^2}\right) \tag{5}\label{eq5} \end{align}

To make the handling a bit simpler, let

$$k = \frac{a^2 b^2}{b^2 + a^2\tan^2(\alpha)} \tag{6}\label{eq6}$$

since $k$ is a constant value. Next, multiplying both sides in \eqref{eq5} by $k$ and then taking square roots gives

$$x - x_0 = \pm\sqrt{k} \; \iff \; x = x_0 \pm\sqrt{k} \tag{7}\label{eq7}$$

Substituting \eqref{eq7} into \eqref{eq4} gives

$$y - y_0 = \pm \sqrt{k} \tan(\alpha) \; \iff \; y = y_0 \pm \sqrt{k} \tan(\alpha) \tag{8}\label{eq8}$$

Thus, the $2$ points of intersection between the line and the ellipse are $\left(x_0 + \sqrt{k}, y_0 + \sqrt{k} \tan(\alpha)\right)$ and $\left(x_0 - \sqrt{k}, y_0 - \sqrt{k} \tan(\alpha)\right)$.

4
On

First, translate the origin to $(x_0,y_0)$ to simplify the expressions that you’re working with. The equation of the ellipse becomes $x^2/a^2+y^2/b^2=1$, and the line now goes through the origin, so its equation is of the form $y=x\tan\alpha$, where $\alpha$ is the angle between line and $x$-axis. You could now substitute for $y$ into the equation of the translated ellipse, solve the resulting quadratic for $x$ and then back-substitute into the equation of the line to find the corresponding values of $y$, but there’s a way that’s perhaps even easier: Transform the problem once more by scaling $x$ and $y$ so that the ellipse becomes a unit circle. This is accomplished by making the substitutions $x\to x'/a$ and $y\to y'/b$.

Before proceeding, I’ll note that equations of the form $y=x\tan\alpha$ don’t cover all possible lines through the origin: the equation of the $y$-axis itself is $x=0$. For this line, $\alpha=\pi/2$, but the tangent of this angle is undefined. We can cover this case, too, by multiplying both sides of the equation by $\cos\alpha$ to get $y\cos\alpha=x\sin\alpha$. This covers all possible lines without any special cases or embarrassing divisions by zero.

For this problem, though, working with a parametric form of the line makes the computations pretty straightforward: the translated line is $(r\cos\alpha,r\sin\alpha)$ and after scaling it’s $\left(\frac ra\cos\alpha,\frac rb\sin\alpha\right)$. We want the value of $r$ for which this point is at a distance of $1$ from the origin: $$\left({r\cos\alpha\over a}\right)+\left({r\sin\alpha\over b}\right)^2=1$$ with solutions $$r = \pm{ab\over\sqrt{\left(b\cos\alpha\right)^2+\left(a\sin\alpha\right)^2}}.$$ Substituting this back into the unscaled line and translating back to the original coordinate system yields $$\left(x_0\pm{ab\cos\alpha\over\sqrt{\left(b\cos\alpha\right)^2+\left(a\sin\alpha\right)^2}},y_0\pm{ab\sin\alpha\over\sqrt{\left(b\cos\alpha\right)^2+\left(a\sin\alpha\right)^2}}\right).$$

Observe that in the process we’ve derived the polar equation of an ellipse centered at the coordinate origin with major axis along $\theta=0$. If you were allowed to take that equation as a given, you could’ve written the solution to the problem down directly.