gtsam
Loading...
Searching...
No Matches
Similarity2.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
17
18#pragma once
19
21#include <gtsam/dllexport.h>
24#include <gtsam/geometry/Rot2.h>
25
26namespace gtsam {
27
28// Forward declarations
29class Pose2;
30
34class GTSAM_EXPORT Similarity2 : public MatrixLieGroup<Similarity2, 4, 3> {
37 typedef Rot2 Rotation;
38 typedef Point2 Translation;
40
41private:
42 Rot2 R_;
43 Point2 t_;
44 double s_;
45
46public:
49
52
54 Similarity2(double s);
55
57 Similarity2(const Rot2& R, const Point2& t, double s);
58
60 Similarity2(const Matrix2& R, const Vector2& t, double s);
61
63 Similarity2(const Matrix3& T);
64
68
70 bool equals(const Similarity2& sim, double tol) const;
71
73 bool operator==(const Similarity2& other) const;
74
76 void print(const std::string& s = "") const;
77
78 GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os,
79 const Similarity2& p);
80
84
86 static Similarity2 Identity();
87
89 Similarity2 operator*(const Similarity2& S) const;
90
92 Similarity2 inverse() const;
93
97
99 Point2 transformFrom(const Point2& p) const;
100
112 Pose2 transformFrom(const Pose2& T) const;
113
114 /* syntactic sugar for transformFrom */
115 Point2 operator*(const Point2& p) const;
116
120 static Similarity2 Align(const Point2Pairs& abPointPairs);
121
135 static Similarity2 Align(const Pose2Pairs& abPosePairs);
136
140
141 using LieAlgebra = Matrix3;
142
144 static Matrix2 GetV(double theta, double lambda);
145
150 static Vector4 Logmap(const Similarity2& S);
151
153 static Similarity2 Expmap(const Vector4& v);
154
157 static Similarity2 Retract(const Vector4& v) {
158 return Similarity2::Expmap(v);
159 }
160 static Vector4 Local(const Similarity2& other) {
161 return Similarity2::Logmap(other);
162 }
163 };
164
166 Matrix4 AdjointMap() const;
167
169
171 static Matrix3 Hat(const Vector4& xi);
172
174 static Vector4 Vee(const Matrix3& X);
175
179
181 Matrix3 matrix() const;
182
184 Rot2 rotation() const { return R_; }
185
187 Point2 translation() const { return t_; }
188
190 double scale() const { return s_; }
191
192 private:
193
194 #if GTSAM_ENABLE_BOOST_SERIALIZATION
196 friend class boost::serialization::access;
197 template<class Archive>
198 void serialize(Archive & ar, const unsigned int /*version*/) {
199 ar & BOOST_SERIALIZATION_NVP(R_);
200 ar & BOOST_SERIALIZATION_NVP(t_);
201 ar & BOOST_SERIALIZATION_NVP(s_);
202 }
203 #endif
204
206};
207
208template <>
209struct traits<Similarity2> : public internal::MatrixLieGroup<Similarity2, 3> {};
210
211template <>
212struct traits<const Similarity2> : public internal::MatrixLieGroup<Similarity2, 3> {};
213
214} // namespace gtsam
Base class and basic functions for Matrix Lie groups.
2D rotation
2D Point
2D Pose
Global functions in a separate testing namespace.
Definition chartTesting.h:28
Vector2 Point2
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point2 to Vector2...
Definition Point2.h:32
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A CRTP helper class that implements Lie group methods Prerequisites: methods operator*,...
Definition Lie.h:114
A CRTP helper class that implements matrix Lie group methods.
Definition MatrixLieGroup.h:51
Both LieGroupTraits and Testable.
Definition MatrixLieGroup.h:350
A 2D pose (Point2,Rot2).
Definition Pose2.h:39
Rotation matrix NOTE: the angle theta is in radians unless explicitly stated.
Definition Rot2.h:40
2D similarity transform
Definition Similarity2.h:34
Point2 translation() const
Return a GTSAM translation.
Definition Similarity2.h:187
Point2 transformFrom(const Point2 &p) const
Action on a point p is s*(R*p+t).
Definition Similarity2.cpp:148
static Similarity2 Align(const Point2Pairs &abPointPairs)
Create Similarity2 by aligning at least two point pairs.
Definition Similarity2.cpp:163
double scale() const
Return the scale.
Definition Similarity2.h:190
bool operator==(const Similarity2 &other) const
Exact equality.
Definition Similarity2.cpp:124
static Matrix2 GetV(double theta, double lambda)
Calculate expmap and logmap coefficients.
Definition Similarity2.cpp:198
static Matrix3 Hat(const Vector4 &xi)
Hat maps from tangent vector to Lie algebra.
Definition Similarity2.cpp:280
static Similarity2 Expmap(const Vector4 &v)
Exponential map at the identity.
Definition Similarity2.cpp:250
Matrix4 AdjointMap() const
Project from one tangent space to another.
Definition Similarity2.cpp:258
Similarity2 inverse() const
Return the inverse.
Definition Similarity2.cpp:142
static Vector4 Logmap(const Similarity2 &S)
Log map at the identity .
Definition Similarity2.cpp:241
static Similarity2 Identity()
Return an identity transform.
Definition Similarity2.cpp:136
bool equals(const Similarity2 &sim, double tol) const
Compare with tolerance.
Definition Similarity2.cpp:118
void print(const std::string &s="") const
Print with optional string.
Definition Similarity2.cpp:128
Matrix3 matrix() const
Calculate 3*3 matrix group equivalent.
Definition Similarity2.cpp:303
Rot2 rotation() const
Return a GTSAM rotation.
Definition Similarity2.h:184
Similarity2 operator*(const Similarity2 &S) const
Composition.
Definition Similarity2.cpp:138
Similarity2()
Default constructor.
Definition Similarity2.cpp:103
static Vector4 Vee(const Matrix3 &X)
Vee maps from Lie algebra to tangent vector.
Definition Similarity2.cpp:289
Chart at the origin.
Definition Similarity2.h:156