2018-10-22 04:11:27 +08:00
|
|
|
use na::{DefaultAllocator, Real};
|
2018-09-21 01:54:12 +08:00
|
|
|
|
2018-09-23 20:48:45 +08:00
|
|
|
use aliases::TVec;
|
2018-10-22 04:11:27 +08:00
|
|
|
use traits::{Alloc, Dimension};
|
2018-09-21 01:54:12 +08:00
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// The dot product of the normalized version of `x` and `y`.
|
2018-10-08 10:30:16 +08:00
|
|
|
///
|
|
|
|
/// This is currently the same as [`normalize_dot`](fn.normalize_dot.html).
|
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`normalize_dot`](fn.normalize_dot.html`)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn fast_normalize_dot<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
|
2018-10-22 13:00:10 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-21 01:54:12 +08:00
|
|
|
// XXX: improve those.
|
|
|
|
x.normalize().dot(&y.normalize())
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// The dot product of the normalized version of `x` and `y`.
|
2018-10-08 10:30:16 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`fast_normalize_dot`](fn.fast_normalize_dot.html`)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn normalize_dot<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
|
2018-10-22 13:00:10 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-21 01:54:12 +08:00
|
|
|
// XXX: improve those.
|
|
|
|
x.normalize().dot(&y.normalize())
|
2018-10-08 10:30:16 +08:00
|
|
|
}
|