skspatial.objects.Sphere.intersect_line

Sphere.intersect_line(line: skspatial.objects.line.Line) Tuple[skspatial.objects.point.Point, skspatial.objects.point.Point][source]

Intersect the sphere with a line.

A line intersects a sphere at two points.

Parameters
lineLine

Input line.

Returns
point_a, point_bPoint

The two points of intersection.

Examples

>>> from skspatial.objects import Sphere, Line
>>> sphere = Sphere([0, 0, 0], 1)
>>> sphere.intersect_line(Line([0, 0, 0], [1, 0, 0]))
(Point([-1.,  0.,  0.]), Point([1., 0., 0.]))
>>> sphere.intersect_line(Line([0, 0, 1], [1, 0, 0]))
(Point([0., 0., 1.]), Point([0., 0., 1.]))
>>> sphere.intersect_line(Line([0, 0, 2], [1, 0, 0]))
Traceback (most recent call last):
...
ValueError: The line does not intersect the sphere.