fj_kernel/algorithms/intersect/
ray_edge.rs1use fj_math::Segment;
4
5use crate::{
6 algorithms::intersect::{HorizontalRayToTheRight, Intersect},
7 geometry::curve::Curve,
8 objects::HalfEdge,
9 storage::Handle,
10};
11
12use super::ray_segment::RaySegmentIntersection;
13
14impl Intersect for (&HorizontalRayToTheRight<2>, &Handle<HalfEdge>) {
15 type Intersection = RaySegmentIntersection;
16
17 fn intersect(self) -> Option<Self::Intersection> {
18 let (ray, edge) = self;
19
20 let line = match edge.curve() {
21 Curve::Line(line) => line,
22 Curve::Circle(_) => {
23 todo!("Casting rays against circles is not supported yet")
24 }
25 };
26
27 let points = edge
28 .boundary()
29 .map(|point| line.point_from_line_coords(point));
30 let segment = Segment::from_points(points);
31
32 (ray, &segment).intersect()
33 }
34}