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