intersection_sphere_line
- compas.geometry.intersection_sphere_line(sphere, line)[source]
Computes the intersection of a sphere and a line.
There are 3 cases of sphere-line intersection : 1) they intersect in 2 points, 2) they intersect in 1 point (line tangent to sphere), or 3) they do not intersect.
- Parameters
sphere (tuple) – center, radius of the sphere.
line (tuple) – xyz coordinates of two points defining the line.
- Returns
None or point or list of points
Examples
>>> from compas.geometry import allclose
>>> sphere = (3.0, 7.0, 4.0), 10.0 >>> line = (1.0, 0, 0.5), (2.0, 1.0, 0.5) >>> x1, x2 = intersection_sphere_line(sphere, line)
>>> allclose(x1, [11.634, 10.634, 0.500], 1e-3) True >>> allclose(x2, [-0.634, -1.634, 0.50], 1e-3) True
References