2021-08-08 18:59:40 +08:00
|
|
|
use crate::RealNumber;
|
2018-09-22 19:18:59 +08:00
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::aliases::TVec3;
|
2018-09-22 19:18:59 +08:00
|
|
|
|
|
|
|
/// The normal vector of the given triangle.
|
|
|
|
///
|
|
|
|
/// The normal is computed as the normalized vector `cross(p2 - p1, p3 - p1)`.
|
2021-08-08 18:59:40 +08:00
|
|
|
pub fn triangle_normal<T: RealNumber>(p1: &TVec3<T>, p2: &TVec3<T>, p3: &TVec3<T>) -> TVec3<T> {
|
2018-09-22 19:18:59 +08:00
|
|
|
(p2 - p1).cross(&(p3 - p1)).normalize()
|
2018-10-22 04:11:27 +08:00
|
|
|
}
|