2018-09-23 20:41:56 +08:00
|
|
|
use na::Real;
|
2018-09-22 19:18:59 +08:00
|
|
|
|
2018-09-23 20:41:56 +08:00
|
|
|
use 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)`.
|
2018-09-23 20:41:56 +08:00
|
|
|
pub fn triangle_normal<N: Real>(p1: &TVec3<N>, p2: &TVec3<N>, p3: &TVec3<N>) -> TVec3<N> {
|
2018-09-22 19:18:59 +08:00
|
|
|
(p2 - p1).cross(&(p3 - p1)).normalize()
|
|
|
|
}
|