chemrust_nasl/geometry/intersections/
mod.rs1mod circle_circle;
2mod circle_point;
3mod circle_sphere;
4mod plane_plane;
5mod sphere_sphere;
6
7use nalgebra::Point3;
8
9pub use circle_circle::CircleCircleIntersection;
10pub use circle_sphere::CircleSphereIntersection;
11pub use sphere_sphere::SphereSphereResult;
12
13#[derive(Debug, Clone, Copy)]
14pub enum FloatOrdering {
15 Less,
16 Equal,
17 Greater,
18}
19
20#[derive(Debug, Clone, Copy)]
21pub enum FloatEq {
22 NotEq,
23 Eq,
24}
25
26pub fn approx_cmp_f64(v1: f64, v2: f64) -> FloatOrdering {
27 if v1 - v2 > 1.0e-5_f64 {
28 FloatOrdering::Greater
29 } else if v1 - v2 < -1.0e-5_f64 {
30 FloatOrdering::Less
31 } else {
32 FloatOrdering::Equal
33 }
34}
35
36pub fn approx_eq_point_f64(p1: Point3<f64>, p2: Point3<f64>) -> FloatEq {
37 let d = p1 - p2;
38 if d.norm_squared() < 3.0 * (1.0e-5_f64).powi(2) {
41 FloatEq::Eq
42 } else {
43 FloatEq::NotEq
44 }
45}
46
47pub trait Intersect<Rhs = Self> {
48 type Output;
49 fn intersect(&self, rhs: &Rhs) -> Self::Output;
50}