intersection_ellipse_line_xy

compas.geometry.intersection_ellipse_line_xy(ellipse, line)[source]

Computes the intersection of an ellipse and a line in the XY plane.

Parameters:
ellipsetuple[float, float]

The major and minor of the ellipse.

line[point, point] | compas.geometry.Line

A line defined by two points, with at least XY coordinates.

Returns:
tuple[[float, float, float], [float, float, float]] | [float, float, float] | None

Two points, if the line goes through the ellipse. One point, if the line is tangent to the ellipse. None, otherwise.

References

Based on [1].

[1]

C# Helper. Calculate where a line segment and an ellipse intersect in C#. Available at: http://csharphelper.com/blog/2017/08/calculate-where-a-line-segment-and-an-ellipse-intersect-in-c/

Examples

>>> ellipse = 6., 2.5
>>> p1 = (4.1, 2.8, 0.)
>>> p2 = (3.4, -3.1, 0.)
>>> i1, i2 = intersection_ellipse_line_xy(ellipse, [p1, p2])