From bf67f079e71ceba2da5391e56a95d2970e1dfe04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Fri, 10 Oct 2014 21:24:18 +0200 Subject: [PATCH] Add a function `nalgebra::center(a, b)` that computes the center of two points. --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index cf10096a..1920f498 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -350,10 +350,17 @@ pub fn one() -> T { /// Returns the trivial origin of an affine space. #[inline(always)] -pub fn orig() -> T { +pub fn orig() -> P { Orig::orig() } +/// Returns the center of two points. +#[inline] +pub fn center, V>(a: &P, b: &P) -> P { + let _2 = one::() + one(); + (*a + *b.as_vec()) / _2 +} + /* * FloatPnt */