summaryrefslogtreecommitdiff
path: root/engine/src/math.rs
blob: b86e76073831f62cc67ccb2fe7fcd3894a8b70b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 - egde_a;
    let v2 = edge_c - egde_a;

    v1.cross(&v2)
}