Skip to content

Commit

Permalink
Add Plane::is_parallel_to_vector
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Sep 30, 2022
1 parent 8db6db1 commit 1f7be33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ impl Intersect for (&HorizontalRayToTheRight<3>, &Face) {
),
};

let plane_and_ray_are_parallel =
plane.normal().dot(&ray.direction()) == Scalar::ZERO;

if plane_and_ray_are_parallel {
if plane.is_parallel_to_vector(&ray.direction()) {
let a = plane.origin();
let b = plane.origin() + plane.u();
let c = plane.origin() + plane.v();
Expand Down
5 changes: 5 additions & 0 deletions crates/fj-math/src/plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ impl Plane {
(distance, normal)
}

/// Determine whether the plane is parallel to the given vector
pub fn is_parallel_to_vector(&self, vector: &Vector<3>) -> bool {
self.normal().dot(vector) == Scalar::ZERO
}

/// Project a line into the plane
pub fn project_line(&self, line: &Line<3>) -> Line<2> {
let line_origin_relative_to_plane = line.origin() - self.origin();
Expand Down

0 comments on commit 1f7be33

Please sign in to comment.