36 CPose2D::CPose2D(
const double x,
const double y,
const double _phi) : m_phi(_phi),m_cossin_uptodate(false)
82 in >> x0 >> y0 >> phi0;
151 R(2,0) = 0;
R(2,1)=0;
R(2,2)=1;
350 return (p1.
x()==p2.
x())&&(p1.
y()==p2.
y())&&(p1.
phi()==p2.
phi());
355 return (p1.
x()!=p2.
x())||(p1.
y()!=p2.
y())||(p1.
phi()!=p2.
phi());
361 const double ccos = pose.
phi_cos();
362 const double ssin = pose.
phi_sin();
364 pose.
x() + u.
x * ccos - u.
y * ssin,
365 pose.
y() + u.
x * ssin + u.
y * ccos );
379 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
381 x( m.get_unsafe(0,0) );
382 y( m.get_unsafe(0,1) );
394 b.getInverseHomogeneousMatrix( B_INV );
398 RES.multiply(B_INV,HM);
410 for (
int i=0;i<3;i++)
411 (*
this)[i] = std::numeric_limits<double>::quiet_NaN();
double x() const
Common members of all points & poses classes.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void setToNaN() MRPT_OVERRIDE
Set all data fields to quiet NaN.
double phi_sin() const
Get a (cached) value of sin(phi), recomputing it only once when phi changes.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
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.
#define THROW_EXCEPTION(msg)
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
void operator*=(const double s)
Scalar multiplication.
void AddComponents(const CPose2D &p)
Scalar sum of components: This is diferent from poses composition, which is implemented as "+" operat...
mrpt::math::CArrayDouble< 2 > m_coords
[x,y]
double z
X,Y,Z coordinates.
void composePoint(double lx, double ly, double &gx, double &gy) const
An alternative, slightly more efficient way of doing with G and L being 2D points and P this 2D pose...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
double m_sinphi
Precomputed cos() & sin() of phi.
T square(const T x)
Inline function for the square of a number.
CPose2D operator-(const CPose2D &b) const
Compute .
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
double RAD2DEG(const double x)
Radians to degrees.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
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...
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void inverse()
Convert this pose into its inverse, saving the result in itself.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
CPose2D operator+(const CPose2D &D) const
The operator is the pose compounding operator.
GLsizei const GLchar ** string
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
A class used to store a 2D point.
A class used to store a 3D point.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
std::string asString() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
size_t size(const MATRIXLIKE &m, const int dim)
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).
CPose2D & operator+=(const CPose2D &b)
Make .
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
const double & phi() const
Get the phi angle of the 2D pose (in radians)
void composeFrom(const CPose2D &A, const CPose2D &B)
Makes .
double phi_cos() const
Get a (cached) value of cos(phi), recomputing it only once when phi changes.
void inverseComposePoint(const double gx, const double gy, double &lx, double &ly) const
Computes the 2D point L such as .
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0...
double distance2DFrobeniusTo(const CPose2D &p) const
Returns the 2D distance from this pose/point to a 2D pose using the Frobenius distance.
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
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...
void getAsVector(mrpt::math::CVectorDouble &v) const
Returns a 1x3 vector with [x y phi].
#define ASSERTMSG_(f, __ERROR_MSG)
CPose2D()
Default constructor (all coordinates to 0)
void normalizePhi()
Forces "phi" to be in the range [-pi,pi];.
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