2019-03-25 18:21:41 +08:00
|
|
|
use na::{DefaultAllocator, RealField};
|
2018-09-21 01:54:12 +08:00
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::aliases::TVec;
|
|
|
|
use crate::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`)
|
2019-03-25 18:21:41 +08:00
|
|
|
pub fn fast_normalize_dot<N: RealField, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
|
2020-04-06 00:49:48 +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`)
|
2019-03-25 18:21:41 +08:00
|
|
|
pub fn normalize_dot<N: RealField, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
|
2020-04-06 00:49:48 +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
|
|
|
}
|