nalgebra/nalgebra-glm/src/gtx/normal.rs
Sébastien Crozet 85074398d0 Fix nalgebra-glm
2021-08-08 12:59:40 +02:00

11 lines
323 B
Rust

use crate::RealNumber;
use crate::aliases::TVec3;
/// The normal vector of the given triangle.
///
/// The normal is computed as the normalized vector `cross(p2 - p1, p3 - p1)`.
pub fn triangle_normal<T: RealNumber>(p1: &TVec3<T>, p2: &TVec3<T>, p3: &TVec3<T>) -> TVec3<T> {
(p2 - p1).cross(&(p3 - p1)).normalize()
}