51 if (m_cossin_uptodate)
return;
53 ::sincos(m_phi,&m_sinphi,&m_cosphi);
55 m_cosphi=::cos(m_phi);
56 m_sinphi=::sin(m_phi);
58 m_cossin_uptodate=
true;
66 CPose2D(
const double x,
const double y,
const double phi);
84 inline const double &
phi()
const {
return m_phi; }
86 inline double &
phi() { m_cossin_uptodate=
false;
return m_phi; }
89 inline double phi_cos()
const { update_cached_cos_sin();
return m_cosphi; }
91 inline double phi_sin()
const { update_cached_cos_sin();
return m_sinphi; }
94 inline void phi(
double angle) { m_phi=angle; m_cossin_uptodate=
false; }
96 inline void phi_incr(
const double Aphi) { m_phi+=Aphi; m_cossin_uptodate=
false; }
113 getRotationMatrix(
R);
131 void composePoint(
double lx,
double ly,
double &gx,
double &gy)
const;
139 void composePoint(
double lx,
double ly,
double lz,
double &gx,
double &gy,
double &gz)
const;
142 void inverseComposePoint(
const double gx,
const double gy,
double &lx,
double &ly)
const;
145 inverseComposePoint(
g.x,
g.y, l.
x,l.
y);
175 void AddComponents(
const CPose2D &
p);
204 case 0:
return m_coords[0];
205 case 1:
return m_coords[1];
208 throw std::runtime_error(
"CPose2D::operator[]: Index of bounds.");
215 case 0:
return m_coords[0];
216 case 1:
return m_coords[1];
219 throw std::runtime_error(
"CPose2D::operator[]: Index of bounds.");
227 double distance2DFrobeniusTo(
const CPose2D &
p)
const;
230 enum { is_3D_val = 0 };
231 static inline bool is_3D() {
return is_3D_val!=0; }
232 enum { rotation_dimensions = 2 };
233 enum { is_PDF_val = 0 };
234 static inline bool is_PDF() {
return is_PDF_val!=0; }
252 static inline bool empty() {
return false; }
254 static inline void resize(
const size_t n) {
if (
n!=
static_size)
throw std::logic_error(
format(
"Try to change the size of CPose2D to %u.",static_cast<unsigned>(
n))); }
void changeCoordinatesReference(const CPose2D &p)
makes: this = p (+) this
double phi_sin() const
Get a (cached) value of sin(phi), recomputing it only once when phi changes.
const type_value & getPoseMean() const
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
#define DEFINE_SERIALIZABLE_PRE(class_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
mrpt::math::TPoint2D BASE_IMPEXP operator+(const CPose2D &pose, const mrpt::math::TPoint2D &pnt)
Compose a 2D point from a new coordinate base given by a 2D pose.
type_value & getPoseMean()
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
mrpt::math::CArrayDouble< 2 > m_coords
[x,y]
std::deque< TYPE1, Eigen::aligned_allocator< TYPE1 > > deque_t
CPose2D(TConstructorFlags_Poses)
Fast constructor that leaves all the data uninitialized - call with UNINITIALIZED_POSE as argument...
double m_sinphi
Precomputed cos() & sin() of phi.
double value_type
The type of the elements.
A numeric matrix of compile-time fixed size.
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
double m_phi
The orientation of the pose, in radians.
CPose2D BASE_IMPEXP operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
A base class for representing a pose in 2D or 3D.
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
mrpt::aligned_containers< CPose2D >::deque_t StdDeque_CPose2D
Eigen aligment-compatible container.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
CPose2D type_value
Used to emulate CPosePDF types, for example, in mrpt::graphs::CNetworkOfPoses.
GLsizei const GLchar ** string
A class used to store a 2D point.
A class used to store a 3D point.
std::string asString() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
double & operator[](unsigned int i)
mrpt::math::CMatrixDouble22 getRotationMatrix() const
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
static size_type max_size()
const double & phi() const
Get the phi angle of the 2D pose (in radians)
static void resize(const size_t n)
double phi_cos() const
Get a (cached) value of cos(phi), recomputing it only once when phi changes.
#define DEFINE_SERIALIZABLE_POST(class_name)
void phi(double angle)
Set the phi angle of the 2D pose (in radians)
const double & const_reference
std::ptrdiff_t difference_type
void inverseComposeFrom(const CPose2D &A, const CPose2D &B)
Makes this method is slightly more efficient than "this= A - B;" since it avoids the temporary objec...
std::vector< T1 > & operator*=(std::vector< T1 > &a, const std::vector< T2 > &b)
a*=b (element-wise multiplication)
const double & operator[](unsigned int i) const
void inverseComposePoint(const mrpt::math::TPoint2D &g, mrpt::math::TPoint2D &l) const
std::vector< TYPE1, Eigen::aligned_allocator< TYPE1 > > vector_t
mrpt::aligned_containers< CPose2D >::vector_t StdVector_CPose2D
Eigen aligment-compatible container.
void phi_incr(const double Aphi)
Increment the PHI angle (without checking the 2 PI range, call normalizePhi is needed) ...
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].
void update_cached_cos_sin() const