I found this page which gave me some equations on solving the intersection of a line with an ellipse given a point on the line and the slope of the line:
There Isn't much explanation but I presume that after solving for $a$, $b$, and $c$, you can then find the roots to the newly formed quadratic, which will give two possible $k$ values.
Here's where the questions come in:
- Which of the two $k$ values do I use in solving for $r$ and $z$?
- How can you tell when the line doesn't intersect the ellipse? Is the quadratic equation for $k$ not have any real roots?
Earlier, the site states:
and that
-
Is it important for $r$ to be greater than zero in for this equation even though I'm not testing a point, but a line instead?
-
Why is the semi-minor axis being defined as $a_e(1-f)$? I usually just define the semi-minor axis the same way I define the major, so could I just replace all the $(1-f)$'s in the above equations with my desired semi-minor axis length?
-
Finally, is there any simpler, faster way to see if and were an ellipse and line intersect?
Best Answer
Either one will be a point of intersection, since in general a line intersects an ellipse in two points. Which one you need, or if it doesn't matter, depends on your application.
Right. And if you only have a single root, i.e. both roots coincide, then the line will be a tangent.
I see no reason to require this here.
Yes, you can write the semi-minor axis (called $a_p$ in your document) instead of $a_e(1-f)$. Which means you could replace the $(1-f)$ themselves by $\frac{a_p}{a_e}$ or multiply the whole equation by $a_e^2$.
Depends on how your objects are given. If you really have an ellipse and a line in the described form, I can't think of something fundamentally easier. If, on the other hand, you have an ellipse in some other representation, then you might be able to use that representation directly to compute the intersection, instead of transforming its representation first. In any case, you can't avoid the quadratic equation.