chemrust_nasl/geometry/intersections/
circle_point.rs

1use nalgebra::Point3;
2
3use crate::geometry::Sphere;
4
5use super::{approx_cmp_f64, Intersect};
6
7#[derive(Debug, Clone, Copy)]
8pub enum PointToSphere {
9    Inside,
10    Outside,
11    OnSurface,
12}
13
14impl Intersect<Point3<f64>> for Sphere {
15    type Output = PointToSphere;
16
17    fn intersect(&self, rhs: &Point3<f64>) -> Self::Output {
18        let op = rhs - self.center();
19        match approx_cmp_f64(op.norm_squared(), self.radius().powi(2)) {
20            super::FloatOrdering::Less => PointToSphere::Inside,
21            super::FloatOrdering::Equal => PointToSphere::OnSurface,
22            super::FloatOrdering::Greater => PointToSphere::Outside,
23        }
24    }
25}