From b0fb28f08715aa5a102f1dd3153c6d4038dc4af8 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Tue, 15 Apr 2025 09:44:09 -0400 Subject: [PATCH] Expmap to .cpp file --- gtsam/geometry/Rot3.h | 13 +++---------- gtsam/geometry/Rot3M.cpp | 6 +++++- gtsam/geometry/Rot3Q.cpp | 6 ++++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/gtsam/geometry/Rot3.h b/gtsam/geometry/Rot3.h index bbdb27818..23d067c70 100644 --- a/gtsam/geometry/Rot3.h +++ b/gtsam/geometry/Rot3.h @@ -374,20 +374,13 @@ class GTSAM_EXPORT Rot3 : public LieGroup { using LieAlgebra = Matrix3; /** - * Exponential map at identity - create a rotation from canonical coordinates + * Exponential map - create a rotation from canonical coordinates * \f$ [R_x,R_y,R_z] \f$ using Rodrigues' formula */ - static Rot3 Expmap(const Vector3& v, OptionalJacobian<3,3> H = {}) { - if(H) *H = Rot3::ExpmapDerivative(v); -#ifdef GTSAM_USE_QUATERNIONS - return traits::Expmap(v); -#else - return Rot3(traits::Expmap(v)); -#endif - } + static Rot3 Expmap(const Vector3& v, OptionalJacobian<3,3> H = {}); /** - * Log map at identity - returns the canonical coordinates + * Log map - returns the canonical coordinates * \f$ [R_x,R_y,R_z] \f$ of this rotation */ static Vector3 Logmap(const Rot3& R, OptionalJacobian<3,3> H = {}); diff --git a/gtsam/geometry/Rot3M.cpp b/gtsam/geometry/Rot3M.cpp index 45e04dab6..df9217767 100644 --- a/gtsam/geometry/Rot3M.cpp +++ b/gtsam/geometry/Rot3M.cpp @@ -153,7 +153,11 @@ Point3 Rot3::rotate(const Point3& p, } /* ************************************************************************* */ -// Log map at identity - return the canonical coordinates of this rotation +Rot3 Rot3::Expmap(const Vector3& v, OptionalJacobian<3,3> H) { + return Rot3(SO3::Expmap(v, H)); +} + +/* ************************************************************************* */ Vector3 Rot3::Logmap(const Rot3& R, OptionalJacobian<3,3> H) { return SO3::Logmap(R.rot_,H); } diff --git a/gtsam/geometry/Rot3Q.cpp b/gtsam/geometry/Rot3Q.cpp index 3e50551d5..2e5b4673a 100644 --- a/gtsam/geometry/Rot3Q.cpp +++ b/gtsam/geometry/Rot3Q.cpp @@ -116,6 +116,12 @@ namespace gtsam { return Point3(r.x(), r.y(), r.z()); } + /* ************************************************************************* */ + Rot3 Rot3::Expmap(const Vector3& v, OptionalJacobian<3,3> H) { + if(H) *H = Rot3::ExpmapDerivative(v); + return traits::Expmap(v); + } + /* ************************************************************************* */ Vector3 Rot3::Logmap(const Rot3& R, OptionalJacobian<3, 3> H) { return traits::Logmap(R.quaternion_, H);