fj_kernel/algorithms/intersect/
mod.rs

1//! Intersection algorithms
2
3pub mod face_point;
4pub mod ray_edge;
5pub mod ray_face;
6pub mod ray_segment;
7
8mod curve_edge;
9mod curve_face;
10mod face_face;
11mod line_segment;
12mod surface_surface;
13
14use fj_math::{Point, Vector};
15
16pub use self::{
17    curve_edge::CurveEdgeIntersection,
18    curve_face::{CurveFaceIntersection, CurveFaceIntersectionInterval},
19    face_face::FaceFaceIntersection,
20    line_segment::LineSegmentIntersection,
21    surface_surface::SurfaceSurfaceIntersection,
22};
23
24/// Compute the intersection between a tuple of objects
25///
26/// # Implementation Note
27///
28/// This trait is newer than most of the intersection algorithms in this module.
29/// Most of them don't support it yet.
30pub trait Intersect {
31    /// The type that describes the intersection between the objects in `Self`
32    type Intersection;
33
34    /// Compute the intersection between a tuple of objects
35    fn intersect(self) -> Option<Self::Intersection>;
36}
37
38/// A horizontal ray that goes to the right
39///
40/// For in-kernel use, we don't need anything more flexible, and being exactly
41/// horizontal simplifies some calculations.
42#[derive(Clone, Copy, Debug, Eq, PartialEq)]
43pub struct HorizontalRayToTheRight<const D: usize> {
44    /// The point where the ray originates
45    pub origin: Point<D>,
46}
47
48impl<const D: usize> HorizontalRayToTheRight<D> {
49    /// Access the direction of this ray
50    pub fn direction(&self) -> Vector<D> {
51        let mut components = [0.; D];
52        components[0] = 1.;
53        components.into()
54    }
55}
56
57impl<P, const D: usize> From<P> for HorizontalRayToTheRight<D>
58where
59    P: Into<Point<D>>,
60{
61    fn from(point: P) -> Self {
62        Self {
63            origin: point.into(),
64        }
65    }
66}