GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
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/geometry/Point2.h>
22 #include <gtsam/base/VectorSpace.h>
23 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
24 #include <boost/serialization/nvp.hpp>
25 #endif
26 
27 namespace gtsam {
28 
34 class GTSAM_EXPORT StereoPoint2 {
35 private:
36 
37  double uL_, uR_, v_;
38 
39 public:
40  enum { dimension = 3 };
43 
46  uL_(0), uR_(0), v_(0) {
47  }
48 
50  StereoPoint2(double uL, double uR, double v) :
51  uL_(uL), uR_(uR), v_(v) {
52  }
53 
55  explicit StereoPoint2(const Vector3& v) :
56  uL_(v(0)), uR_(v(1)), v_(v(2)) {}
57 
61 
63  void print(const std::string& s = "") const;
64 
66  bool equals(const StereoPoint2& q, double tol = 1e-9) const {
67  return (std::abs(uL_ - q.uL_) < tol && std::abs(uR_ - q.uR_) < tol
68  && std::abs(v_ - q.v_) < tol);
69  }
70 
74 
76  inline static StereoPoint2 Identity() {
77  return StereoPoint2();
78  }
79 
82  return StereoPoint2(-uL_, -uR_, -v_);
83  }
84 
86  inline StereoPoint2 operator +(const Vector3& v) const {
87  return StereoPoint2(uL_ + v[0], uR_ + v[1], v_ + v[2]);
88  }
89 
91  inline StereoPoint2 operator +(const StereoPoint2& b) const {
92  return StereoPoint2(uL_ + b.uL_, uR_ + b.uR_, v_ + b.v_);
93  }
94 
96  inline StereoPoint2 operator -(const StereoPoint2& b) const {
97  return StereoPoint2(uL_ - b.uL_, uR_ - b.uR_, v_ - b.v_);
98  }
99 
103 
105  inline bool operator ==(const StereoPoint2& q) const {return uL_== q.uL_ && uR_==q.uR_ && v_ == q.v_;}
106 
108  inline double uL() const {return uL_;}
109 
111  inline double uR() const {return uR_;}
112 
114  inline double v() const {return v_;}
115 
117  Vector3 vector() const {
118  return Vector3(uL_, uR_, v_);
119  }
120 
122  Point2 point2() const {
123  return Point2(uL_, v_);
124  }
125 
127  Point2 right() const {
128  return Point2(uR_, v_);
129  }
130 
133  inline StereoPoint2 inverse() const { return StereoPoint2()- (*this);}
134  inline StereoPoint2 compose(const StereoPoint2& p1) const { return *this + p1;}
135  inline StereoPoint2 between(const StereoPoint2& p2) const { return p2 - *this; }
136  inline Vector localCoordinates(const StereoPoint2& t2) const { return Logmap(between(t2)); }
137  inline StereoPoint2 retract(const Vector& v) const { return compose(Expmap(v)); }
138  static inline Vector Logmap(const StereoPoint2& p) { return p.vector(); }
139  static inline StereoPoint2 Expmap(const Vector& d) { return StereoPoint2(d(0), d(1), d(2)); }
141 
143  GTSAM_EXPORT friend std::ostream &operator<<(std::ostream &os, const StereoPoint2& p);
144 
145 private:
146 
150 
151 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
152 
153  friend class boost::serialization::access;
154  template<class ARCHIVE>
155  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
156  ar & BOOST_SERIALIZATION_NVP(uL_);
157  ar & BOOST_SERIALIZATION_NVP(uR_);
158  ar & BOOST_SERIALIZATION_NVP(v_);
159  }
160 #endif
161 
163 
164 };
165 
166 typedef std::vector<StereoPoint2> StereoPoint2Vector;
167 
168 template<>
169 struct traits<StereoPoint2> : public internal::VectorSpace<StereoPoint2> {};
170 
171 template<>
172 struct traits<const StereoPoint2> : public internal::VectorSpace<StereoPoint2> {};
173 }
VectorSpace provides both Testable and VectorSpaceTraits.
Definition: VectorSpace.h:207
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
Vector2 Point2
Definition: Point2.h:32
Definition: Group.h:43
bool operator==(const Matrix &A, const Matrix &B)
Definition: Matrix.h:99
Point2 right() const
Definition: StereoPoint2.h:127
StereoPoint2(double uL, double uR, double v)
Definition: StereoPoint2.h:50
StereoPoint2 operator-() const
inverse
Definition: StereoPoint2.h:81
Vector3 vector() const
Definition: StereoPoint2.h:117
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
double v() const
get v
Definition: StereoPoint2.h:114
StereoPoint2()
Definition: StereoPoint2.h:45
static StereoPoint2 Identity()
identity
Definition: StereoPoint2.h:76
Definition: chartTesting.h:28
Definition: StereoPoint2.h:34
double uL() const
get uL
Definition: StereoPoint2.h:108
GTSAM_EXPORT Errors operator-(const Errors &a, const Errors &b)
Subtraction.
2D Point
StereoPoint2(const Vector3 &v)
construct from 3D vector
Definition: StereoPoint2.h:55
double uR() const
get uR
Definition: StereoPoint2.h:111
GTSAM_EXPORT Errors operator+(const Errors &a, const Errors &b)
Addition.
Point2 point2() const
Definition: StereoPoint2.h:122
bool equals(const StereoPoint2 &q, double tol=1e-9) const
Definition: StereoPoint2.h:66