gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StereoPoint2.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 
19 #pragma once
20 
21 #include <gtsam/base/DerivedValue.h>
22 #include <gtsam/geometry/Point2.h>
23 
24 namespace gtsam {
25 
31  class GTSAM_EXPORT StereoPoint2 : public DerivedValue<StereoPoint2> {
32  public:
33  static const size_t dimension = 3;
34  private:
35  double uL_, uR_, v_;
36 
37  public:
38 
41 
44  uL_(0), uR_(0), v_(0) {
45  }
46 
48  StereoPoint2(double uL, double uR, double v) :
49  uL_(uL), uR_(uR), v_(v) {
50  }
51 
55 
57  void print(const std::string& s="") const;
58 
60  bool equals(const StereoPoint2& q, double tol=1e-9) const {
61  return (fabs(uL_ - q.uL_) < tol && fabs(uR_ - q.uR_) < tol && fabs(v_
62  - q.v_) < tol);
63  }
64 
68 
70  inline static StereoPoint2 identity() { return StereoPoint2(); }
71 
73  inline StereoPoint2 inverse() const {
74  return StereoPoint2()- (*this);
75  }
76 
78  inline StereoPoint2 compose(const StereoPoint2& p1) const {
79  return *this + p1;
80  }
81 
84  return StereoPoint2(uL_ + b.uL_, uR_ + b.uR_, v_ + b.v_);
85  }
86 
89  return StereoPoint2(uL_ - b.uL_, uR_ - b.uR_, v_ - b.v_);
90  }
91 
95 
97  inline static size_t Dim() { return dimension; }
98 
100  inline size_t dim() const { return dimension; }
101 
103  inline StereoPoint2 retract(const Vector& v) const { return compose(Expmap(v)); }
104 
106  inline Vector localCoordinates(const StereoPoint2& t2) const { return Logmap(between(t2)); }
107 
111 
113  static inline StereoPoint2 Expmap(const Vector& d) {
114  return StereoPoint2(d(0), d(1), d(2));
115  }
116 
118  static inline Vector Logmap(const StereoPoint2& p) {
119  return p.vector();
120  }
121 
123  inline StereoPoint2 between(const StereoPoint2& p2) const {
124  return gtsam::between_default(*this, p2);
125  }
126 
130 
132  inline double uL() const {return uL_;}
133 
135  inline double uR() const {return uR_;}
136 
138  inline double v() const {return v_;}
139 
141  Vector3 vector() const {
142  return Vector3(uL_, uR_, v_);
143  }
144 
146  inline Point2 point2(){
147  return Point2(uL_, v_);
148  }
149 
151  inline Point2 right(){
152  return Point2(uR_, v_);
153  }
154 
155  private:
156 
160 
162  friend class boost::serialization::access;
163  template<class ARCHIVE>
164  void serialize(ARCHIVE & ar, const unsigned int version) {
165  ar & boost::serialization::make_nvp("StereoPoint2",
166  boost::serialization::base_object<Value>(*this));
167  ar & BOOST_SERIALIZATION_NVP(uL_);
168  ar & BOOST_SERIALIZATION_NVP(uR_);
169  ar & BOOST_SERIALIZATION_NVP(v_);
170  }
171 
173 
174  };
175 
176 }
StereoPoint2 inverse() const
inverse
Definition: StereoPoint2.h:73
Definition: StereoPoint2.h:31
Definition: Point2.h:35
size_t dim() const
return dimensionality of tangent space, DOF = 3
Definition: StereoPoint2.h:100
bool equals(const StereoPoint2 &q, double tol=1e-9) const
equals
Definition: StereoPoint2.h:60
2D Point
Point2 point2()
convenient function to get a Point2 from the left image
Definition: StereoPoint2.h:146
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
T between_default(const T &l1, const T &l2)
These core global functions can be specialized by new Lie types for better performance.
Definition: Lie.h:34
StereoPoint2(double uL, double uR, double v)
constructor
Definition: StereoPoint2.h:48
static StereoPoint2 identity()
identity
Definition: StereoPoint2.h:70
static StereoPoint2 Expmap(const Vector &d)
Exponential map around identity - just create a Point2 from a vector.
Definition: StereoPoint2.h:113
StereoPoint2 compose(const StereoPoint2 &p1) const
"Compose", just adds the coordinates of two points.
Definition: StereoPoint2.h:78
Point2 right()
convenient function to get a Point2 from the right image
Definition: StereoPoint2.h:151
StereoPoint2()
default constructor
Definition: StereoPoint2.h:43
static size_t Dim()
dimension of the variable - used to autodetect sizes */
Definition: StereoPoint2.h:97
Vector3 vector() const
convert to vector
Definition: StereoPoint2.h:141
StereoPoint2 operator-(const StereoPoint2 &b) const
subtract two stereo points
Definition: StereoPoint2.h:88
static Vector Logmap(const StereoPoint2 &p)
Log map around identity - just return the Point2 as a vector.
Definition: StereoPoint2.h:118
double uR() const
get uR
Definition: StereoPoint2.h:135
Vector localCoordinates(const StereoPoint2 &t2) const
Returns inverse retraction.
Definition: StereoPoint2.h:106
Definition: DerivedValue.h:44
double v() const
get v
Definition: StereoPoint2.h:138
StereoPoint2 between(const StereoPoint2 &p2) const
The difference between another point and this point.
Definition: StereoPoint2.h:123
StereoPoint2 retract(const Vector &v) const
Updates a with tangent space delta.
Definition: StereoPoint2.h:103
StereoPoint2 operator+(const StereoPoint2 &b) const
add two stereo points
Definition: StereoPoint2.h:83
double uL() const
get uL
Definition: StereoPoint2.h:132