Projecting line onto edge of ellipse?

143 Views Asked by At

I feel like the answer to this should be fairly simple, but I am absolutely hitting a brick wall here.

I have a line, with angle $\beta$ and origin $(x_l, y_l)$.

I have a rotated ellipse, with major axes $a$ and $b$, and rotation angle of $\alpha$, around center $(h, k)$.

The parametric equations for the ellipse are:

$x = a \cos t \cos \alpha - b \sin t \sin \alpha + h$

$y = b \sin t \cos \alpha + a \cos t \sin \alpha + k$

Here is a picture describing the scenario/what I want:

Line and ellipse

The line is in red, and when it would otherwise be on the inside of the ellipse, I want to find the locations that points on the line would have on the border instead. My line is also discretized into individual points, so essentially I want to find what projection the dotted points would have onto the edge of the ellipse. Basically, I actually care about how an arbitrary point $(x_p, y_p)$ on the dotted line would be 'pushed outside' the ellipse, and its new coordinates.

I feel like this should really be straight forward, but I'm just very confused about how to proceed - finding the parameter $t$ of the intersecting points seems like the way to start, but how to solve for $t$ in closed form in this case?

Thank you so much for any hints or guidance. Hopefully this is a clear enough explanation!

EDIT: Some clarifications. In the following figure, I want to find $(x_e, y_e)$ given $(x_p, y_p)$ given that the blue dotted line is orthogonal to the red dotted line.

Ellipse and line, clarified.

1

There are 1 best solutions below

0
On BEST ANSWER

I'd take a generic point on the blue line, i.e.

$$P(\lambda) = (x_p,y_p)+\lambda(-\sin\beta,\cos\beta)$$

and plug that into the equation for the ellipse, which will give you a quadratic equation in $\lambda$ whose solutions correspond to the points of intersection. From these two points of intersection, you may want to either pick the one closer to $(x_p,y_p)$ (i.e. the one with smaller absolute value $\lvert\lambda\rvert$) or the one on the chosen side of the red line, (e.g. the one with $\lambda>0$).

For the equation of the ellipse, you need an implicit form. So you subtract the center, undo the rotation and then write down the general form of an axis-aligned and origin-centered ellipse.

$$\begin{pmatrix} \cos\alpha & \sin\alpha \\ -\sin\alpha & \cos\alpha \end{pmatrix}\cdot \begin{pmatrix}x-h\\y-k\end{pmatrix} = \begin{pmatrix} (x-h)\cos\alpha+(y-k)\sin\alpha\\ -(x-h)\sin\alpha+(y-k)\cos\alpha \end{pmatrix} \\ \left(\frac{(x-h)\cos\alpha+(y-k)\sin\alpha}{a}\right)^2+ \left(\frac{-(x-h)\sin\alpha+(y-k)\cos\alpha}{b}\right)^2=1 $$