1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
use na::{Real, DefaultAllocator};

use traits::{Dimension, Alloc};
use aliases::TVec;

/// The dot product of the normalized version of `x` and `y`.
pub fn fast_normalize_dot<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
    where DefaultAllocator: Alloc<N, D> {
    // XXX: improve those.
    x.normalize().dot(&y.normalize())
}

/// The dot product of the normalized version of `x` and `y`.
pub fn normalize_dot<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
    where DefaultAllocator: Alloc<N, D> {
    // XXX: improve those.
    x.normalize().dot(&y.normalize())
}