Add a function nalgebra::center(a, b) that computes the center of two points.

This commit is contained in:
Sébastien Crozet 2014-10-10 21:24:18 +02:00
parent b3e7540b3c
commit bf67f079e7

View File

@ -350,10 +350,17 @@ pub fn one<T: One>() -> T {
/// Returns the trivial origin of an affine space.
#[inline(always)]
pub fn orig<T: Orig>() -> T {
pub fn orig<P: Orig>() -> P {
Orig::orig()
}
/// Returns the center of two points.
#[inline]
pub fn center<N: Float, P: FloatPnt<N, V>, V>(a: &P, b: &P) -> P {
let _2 = one::<N>() + one();
(*a + *b.as_vec()) / _2
}
/*
* FloatPnt
*/