From ebf906a23a9c4a92f8ea3a8b783f0070ae3f87f3 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 19 Dec 2008 16:31:22 +0000 Subject: [PATCH] add matrix * transform product --- Eigen/src/Geometry/Transform.h | 7 +++++++ test/geometry.cpp | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 5d7f610cb..d62a9c98d 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -184,6 +184,13 @@ public: operator * (const MatrixBase &other) const { return ei_transform_product_impl::run(*this,other.derived()); } + /** \returns the product expression of a transformation matrix \a a times a transform \a b + * The transformation matrix \a a must have a Dim+1 x Dim+1 sizes. */ + template + friend inline const typename ProductReturnType::Type + operator * (const MatrixBase &a, const Transform &b) + { return a.derived() * b.matrix(); } + /** Contatenates two transformations */ inline const Transform operator * (const Transform& other) const diff --git a/test/geometry.cpp b/test/geometry.cpp index 9885380ca..8c0d3b688 100644 --- a/test/geometry.cpp +++ b/test/geometry.cpp @@ -180,7 +180,7 @@ template void geometry(void) VERIFY_IS_APPROX(t0.prescale(a).matrix(), t1.prescale(Vector3::Constant(a)).matrix()); // More transform constructors, operator=, operator*= - + Scalar a3 = ei_random(-M_PI, M_PI); Vector3 v3 = Vector3::Random().normalized(); AngleAxisx aa3(a3, v3); @@ -212,6 +212,9 @@ template void geometry(void) t4 *= sv3; VERIFY_IS_APPROX(t6.matrix(), t4.matrix()); + // matrix * transform + VERIFY_IS_APPROX(Transform3(t3.matrix()*t4).matrix(), Transform3(t3*t4).matrix()); + // chained Transform product VERIFY_IS_APPROX(((t3*t4)*t5).matrix(), (t3*(t4*t5)).matrix()); @@ -220,8 +223,6 @@ template void geometry(void) t5 = t5*t5; VERIFY_IS_APPROX(t5, t4*t4); - - // 2D transformation Transform2 t20, t21; Vector2 v20 = Vector2::Random();