-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #949 from hannobraun/ray
Merge ray casting code into `intersect` module
- Loading branch information
Showing
8 changed files
with
126 additions
and
137 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Intersection between a ray and an edge in 2D | ||
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().expect_vertices().map(|vertex| { | ||
let point = vertex.position(); | ||
line.point_from_line_coords(point) | ||
}); | ||
let segment = Segment::from_points(points); | ||
|
||
(ray, &segment).intersect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ mod sweep; | |
mod transform; | ||
mod triangulate; | ||
|
||
pub mod cast_ray; | ||
pub mod intersect; | ||
|
||
pub use self::{ | ||
|
Oops, something went wrong.