use na::{Real, DefaultAllocator}; use traits::{Number, Dimension, Alloc}; use aliases::{Vec, TVec2, TVec3}; /// Returns `true` if two vectors are collinear (up to an epsilon). pub fn are_collinear(v0: &TVec3, v1: &TVec3, epsilon: N) -> bool { is_null(&v0.cross(v1), epsilon) } /// Returns `true` if two 2D vectors are collinear (up to an epsilon). pub fn are_collinear2d(v0: &TVec2, v1: &TVec2, epsilon: N) -> bool { abs_diff_eq!(v0.perp(v1), N::zero(), epsilon = epsilon) } /// Returns `true` if two vectors are orthogonal (up to an epsilon). pub fn are_orthogonal(v0: &Vec, v1: &Vec, epsilon: N) -> bool where DefaultAllocator: Alloc { abs_diff_eq!(v0.dot(v1), N::zero(), epsilon = epsilon) } //pub fn are_orthonormal(v0: &Vec, v1: &Vec, epsilon: N) -> bool // where DefaultAllocator: Alloc { // unimplemented!() //} /// Returns `true` if all the components of `v` are zero (up to an epsilon). pub fn is_comp_null(v: &Vec, epsilon: N) -> Vec where DefaultAllocator: Alloc { v.map(|x| abs_diff_eq!(x, N::zero(), epsilon = epsilon)) } /// Returns `true` if `v` has a magnitude of 1 (up to an epsilon). pub fn is_normalized(v: &Vec, epsilon: N) -> bool where DefaultAllocator: Alloc { abs_diff_eq!(v.norm_squared(), N::one(), epsilon = epsilon * epsilon) } /// Returns `true` if `v` is zero (up to an epsilon). pub fn is_null(v: &Vec, epsilon: N) -> bool where DefaultAllocator: Alloc { abs_diff_eq!(*v, Vec::::zeros(), epsilon = epsilon) }