diff options
Diffstat (limited to 'engine/src/math.rs')
-rw-r--r-- | engine/src/math.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/engine/src/math.rs b/engine/src/math.rs new file mode 100644 index 0000000..bda3b59 --- /dev/null +++ b/engine/src/math.rs @@ -0,0 +1,17 @@ +//! Miscellaneous math functions. + +use crate::vector::Vec3; + +/// Calculates the surface normal of a triangle. +#[must_use] +pub fn calc_triangle_surface_normal( + egde_a: &Vec3<f32>, + edge_b: &Vec3<f32>, + edge_c: &Vec3<f32>, +) -> Vec3<f32> +{ + let v1 = edge_b.clone() - egde_a.clone(); + let v2 = edge_c.clone() - egde_a.clone(); + + v1.cross(&v2) +} |