``` 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
```
```use na::{DefaultAllocator, RealField};

use crate::aliases::{TVec, TVec2, TVec3};
use crate::traits::{Alloc, Dimension, Number};

/// Returns `true` if two vectors are collinear (up to an epsilon).
///
///
/// * [`are_collinear2d`](fn.are_collinear2d.html)
pub fn are_collinear<N: Number>(v0: &TVec3<N>, v1: &TVec3<N>, epsilon: N) -> bool {
is_null(&v0.cross(v1), epsilon)
}

/// Returns `true` if two 2D vectors are collinear (up to an epsilon).
///
///
/// * [`are_collinear`](fn.are_collinear.html)
pub fn are_collinear2d<N: Number>(v0: &TVec2<N>, v1: &TVec2<N>, 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<N: Number, D: Dimension>(
v0: &TVec<N, D>,
v1: &TVec<N, D>,
epsilon: N,
) -> bool
where
DefaultAllocator: Alloc<N, D>,
{
abs_diff_eq!(v0.dot(v1), N::zero(), epsilon = epsilon)
}

//pub fn are_orthonormal<N: Number, D: Dimension>(v0: &TVec<N, D>, v1: &TVec<N, D>, epsilon: N) -> bool
//    where DefaultAllocator: Alloc<N, D> {
//    unimplemented!()
//}

/// Returns `true` if all the components of `v` are zero (up to an epsilon).
pub fn is_comp_null<N: Number, D: Dimension>(v: &TVec<N, D>, epsilon: N) -> TVec<bool, D>
where DefaultAllocator: Alloc<N, D> {
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<N: RealField, D: Dimension>(v: &TVec<N, D>, epsilon: N) -> bool
where DefaultAllocator: Alloc<N, D> {
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<N: Number, D: Dimension>(v: &TVec<N, D>, epsilon: N) -> bool
where DefaultAllocator: Alloc<N, D> {
abs_diff_eq!(*v, TVec::<N, D>::zeros(), epsilon = epsilon)
}
```