pub fn continuous_line2_sphere2<S>(
line: &Line2<S>,
sphere: &Sphere2<S>,
) -> Option<((S, Point2<S>), (S, Point2<S>))>where
S: Real,
Expand description
Compute the intersection of a 2D line with a 2D sphere (circle).
If the line and circle intersect, the two intersection points are returned with the scalar parameter corresponding to that point along the line.
let sphere = Sphere2::unit();
let line = Line2::new ([0.0, 0.0].into(), Unit2::axis_x());
assert_eq!(
continuous_line2_sphere2 (&line, &sphere).unwrap(),
( (-1.0, [-1.0, 0.0].into()),
( 1.0, [ 1.0, 0.0].into())
)
);
Returns None
if the line and circle are tangent:
let sphere = Sphere2::unit();
let line = Line2::new ([0.0, 1.0].into(), Unit2::axis_x());
assert_eq!(continuous_line2_sphere2 (&line, &sphere), None);