From fc782f3644c5fe304a1b6f3858b61287de7c6d24 Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Mon, 29 Oct 2018 12:48:53 +0100 Subject: [PATCH] Make MatrixN::{transform_vector, transform_point} inherent methods. Addresses https://github.com/rustsim/nalgebra/issues/372 --- src/base/cg.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/base/cg.rs b/src/base/cg.rs index 01be4e99..2a97607e 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -314,11 +314,12 @@ impl> SquareMatrix } } -impl> Transformation>> for MatrixN +impl, S: Storage> SquareMatrix where DefaultAllocator: Allocator + Allocator> + Allocator, DimNameDiff> { + /// Transforms the given vector, assuming the matirx `self` uses homogeneous coordinates. #[inline] fn transform_vector( &self, @@ -336,6 +337,7 @@ where DefaultAllocator: Allocator transform * v } + /// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates. #[inline] fn transform_point(&self, pt: &Point>) -> Point> { let transform = self.fixed_slice::, DimNameDiff>(0, 0); @@ -351,3 +353,23 @@ where DefaultAllocator: Allocator transform * pt + translation } } + +impl> Transformation>> for MatrixN +where DefaultAllocator: Allocator + + Allocator> + + Allocator, DimNameDiff> +{ + #[inline] + fn transform_vector( + &self, + v: &VectorN>, + ) -> VectorN> + { + self.transform_vector(v) + } + + #[inline] + fn transform_point(&self, pt: &Point>) -> Point> { + self.transform_point(pt) + } +}