Skip to content

Commit

Permalink
math::get_arbitrary_line_perpendicular
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Jun 19, 2024
1 parent 453aa9a commit 681fdcf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fyrox-math/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,21 @@ where
closest_index
}

#[inline]
pub fn get_arbitrary_line_perpendicular(
begin: Vector3<f32>,
end: Vector3<f32>,
) -> Option<Vector3<f32>> {
let dir = (end - begin).try_normalize(f32::EPSILON)?;
for axis in [Vector3::x(), Vector3::y(), Vector3::z()] {
let perp = dir.cross(&axis);
if perp.norm_squared().ne(&0.0) {
return Some(perp);
}
}
None
}

/// Returns a tuple of (point index; triangle index) closest to the given point.
#[inline]
pub fn get_closest_point_triangle_set<P>(
Expand Down

0 comments on commit 681fdcf

Please sign in to comment.