21 #include <type_traits> 68 constexpr
TPoint2D(
double xx,
double yy) :
x(xx),
y(yy) {}
83 throw std::out_of_range(
"index out of range");
96 throw std::out_of_range(
"index out of range");
142 return {
x +
p.
x,
y +
p.y};
147 return {
x -
p.
x,
y -
p.y};
177 static size_t size() {
return 2; }
234 throw std::out_of_range(
"index out of range");
249 throw std::out_of_range(
"index out of range");
281 const double ccos = ::cos(
phi), csin = ::sin(
phi);
282 return {
x + l.
x * ccos - l.
y * csin,
y + l.
x * csin + l.
y * ccos};
292 const double Ax =
g.
x -
x, Ay =
g.y -
y, ccos = ::cos(
phi),
294 return { Ax * ccos + Ay * csin, -Ax * csin + Ay * ccos };
309 constexpr
static size_t size() {
return 3; }
326 constexpr
TPoint3Df(
const float xx,
const float yy,
const float zz)
327 :
x(xx),
y(yy),
z(zz)
353 throw std::out_of_range(
"index out of range");
369 throw std::out_of_range(
"index out of range");
388 constexpr
TPoint3D(
double xx,
double yy,
double zz) :
x(xx),
y(yy),
z(zz) {}
419 throw std::out_of_range(
"index out of range");
434 throw std::out_of_range(
"index out of range");
471 template <
class VECTORLIKE>
504 return {
x +
p.
x,
y +
p.y,
z +
p.z};
511 return {
x -
p.
x,
y -
p.y,
z -
p.z};
516 return {
x * d,
y * d,
z * d};
521 return {
x / d,
y / d,
z / d};
547 static constexpr
size_t size() {
return 3; }
570 :
pt(
x,
y,
z),
R(R_val),
G(G_val),
B(B_val)
593 :
pt(
x,
y,
z),
R(R_val),
G(G_val),
B(B_val)
637 double _x,
double _y,
double _z,
double _yaw,
double _pitch,
664 throw std::out_of_range(
"index out of range");
685 throw std::out_of_range(
"index out of range");
752 static size_t size() {
return 6; }
759 TPose3D
operator-(
const TPose3D&
b,
const TPose3D&
a);
778 double _x,
double _y,
double _z,
double _qr,
double _qx,
double _qy,
780 :
x(_x),
y(_y),
z(_z),
qr(_qr),
qx(_qx),
qy(_qy),
qz(_qz)
805 throw std::out_of_range(
"index out of range");
828 throw std::out_of_range(
"index out of range");
837 for (
size_t i = 0; i < 7; i++)
v[i] = (*
this)[i];
860 static size_t size() {
return 7; }
864 std::ostream&
operator<<(std::ostream& o,
const TPoint2D&
p);
865 std::ostream&
operator<<(std::ostream& o,
const TPoint3D&
p);
866 std::ostream&
operator<<(std::ostream& o,
const TPose2D&
p);
867 std::ostream&
operator<<(std::ostream& o,
const TPose3D&
p);
868 std::ostream&
operator<<(std::ostream& o,
const TPose3DQuat&
p);
875 return {-p1.
x, -p1.
y, -p1.
z};
882 return (p1.
x == p2.
x) && (p1.
y == p2.
y);
889 return (p1.
x != p2.
x) || (p1.
y != p2.
y);
896 return (p1.
x == p2.
x) && (p1.
y == p2.
y) && (p1.
z == p2.
z);
903 return (p1.
x != p2.
x) || (p1.
y != p2.
y) || (p1.
z != p2.
z);
910 return (p1.
x == p2.
x) && (p1.
y == p2.
y) &&
919 return (p1.
x != p2.
x) || (p1.
y != p2.
y) ||
928 return (p1.
x == p2.
x) && (p1.
y == p2.
y) && (p1.
z == p2.
z) &&
940 return (p1.
x != p2.
x) || (p1.
y != p2.
y) || (p1.
z != p2.
z) ||
995 throw std::out_of_range(
"index out of range");
1008 throw std::out_of_range(
"index out of range");
1081 throw std::out_of_range(
"index out of range");
1094 throw std::out_of_range(
"index out of range");
1234 explicit TLine2D(
const TLine3D& l);
1237 const TPoint2D& origin, TPose2D& outPose)
const;
1272 for (
size_t i = 0; i < 3; i++) vector[i] =
director[i];
1383 constexpr
TPlane(
double A,
double B,
double C,
double D) :
1392 for (
size_t i = 0; i < 4; i++)
coefs[i] = vec[i];
1426 void getPlotData(std::vector<double>&
x, std::vector<double>&
y)
const;
1443 size_t numEdges,
double radius,
TPolygon2D& poly);
1450 size_t numEdges,
double radius,
TPolygon2D& poly,
1498 size_t numEdges,
double radius,
TPolygon3D& poly);
1505 size_t numEdges,
double radius,
TPolygon3D& poly,
1678 p = *(
data.polygon);
1689 if (
this == &
obj)
return *
this;
1697 data.segment =
obj.data.segment;
1759 const std::vector<TObject2D>& objs, std::vector<TPoint2D>& pnts);
1764 const std::vector<TObject2D>& objs, std::vector<TSegment2D>& sgms);
1769 const std::vector<TObject2D>& objs, std::vector<TLine2D>& lins);
1774 const std::vector<TObject2D>& objs, std::vector<TPolygon2D>& polys);
1780 const std::vector<TObject2D>& objs, std::vector<TPoint2D>& pnts,
1781 std::vector<TObject2D>& remainder);
1787 const std::vector<TObject2D>& objs, std::vector<TSegment2D>& sgms,
1788 std::vector<TObject2D>& remainder);
1794 const std::vector<TObject2D>& objs, std::vector<TLine2D>& lins,
1795 std::vector<TObject2D>& remainder);
1801 const std::vector<TObject2D>& objs, std::vector<TPolygon2D>& polys,
1802 std::vector<TObject2D>& remainder);
1949 p = *(
data.polygon);
1974 if (
this == &
obj)
return *
this;
1982 data.segment =
obj.data.segment;
2067 throw std::logic_error(
"Too many dimensions");
2084 const std::vector<TObject3D>& objs, std::vector<TPoint3D>& pnts);
2089 const std::vector<TObject3D>& objs, std::vector<TSegment3D>& sgms);
2094 const std::vector<TObject3D>& objs, std::vector<TLine3D>& lins);
2099 const std::vector<TObject3D>& objs, std::vector<TPlane>& plns);
2104 const std::vector<TObject3D>& objs, std::vector<TPolygon3D>& polys);
2110 const std::vector<TObject3D>& objs, std::vector<TPoint3D>& pnts,
2111 std::vector<TObject3D>& remainder);
2117 const std::vector<TObject3D>& objs, std::vector<TSegment3D>& sgms,
2118 std::vector<TObject3D>& remainder);
2124 const std::vector<TObject3D>& objs, std::vector<TLine3D>& lins,
2125 std::vector<TObject3D>& remainder);
2131 const std::vector<TObject3D>& objs, std::vector<TPlane>& plns,
2132 std::vector<TObject3D>& remainder);
2138 const std::vector<TObject3D>& objs, std::vector<TPolygon3D>& polys,
2139 std::vector<TObject3D>& remainder);
2157 constexpr
TTwist2D(
double vx_,
double vy_,
double omega_)
2175 throw std::out_of_range(
"index out of range");
2190 throw std::out_of_range(
"index out of range");
2203 void rotate(
const double ang);
2246 double vx_,
double vy_,
double vz_,
double wx_,
double wy_,
double wz_)
2270 throw std::out_of_range(
"index out of range");
2291 throw std::out_of_range(
"index out of range");
2298 for (
int i = 0; i < 6; i++)
v[i] = (*
this)[i];
2329 template <
class PoseOrPoint,
typename = std::enable_if_t<std::is_base_of<
2334 for (
int i = 0; i < o.static_size; i++)
in >> o[i];
2337 template <
class PoseOrPoint,
typename = std::enable_if_t<std::is_base_of<
2342 for (
int i = 0; i < o.static_size; i++) out << o[i];
void getCenter(TPoint2D &p) const
Segment's central point.
TSegment2D(const TPoint2D &p1, const TPoint2D &p2)
Constructor from both points.
TPoint2D & operator+=(const TPoint2D &p)
double & operator[](size_t i)
Coordinate access using operator[].
static constexpr size_t size()
static void getSegments(const std::vector< TObject2D > &objs, std::vector< TSegment2D > &sgms)
Static method to retrieve all the segments in a vector of TObject2D.
bool getPoint(TPoint2D &p) const
Gets the content as a point, returning false if the type is inadequate.
void getUnitaryNormalVector(double(&vector)[2])
Get line's normal vector after unitarizing line.
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D &poly)
Static method to create a regular polygon, given its size and radius.
static void createRegularPolygon(size_t numEdges, double radius, TPolygon2D &poly)
Static method to create a regular polygon, given its size and radius.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" ) ...
TPolygon3D(const std::vector< TPoint3D > &v)
Implicit constructor from a 3D points vector.
constexpr TPose3DQuat(double _x, double _y, double _z, double _qr, double _qx, double _qy, double _qz)
Constructor from coordinates.
constexpr const double & operator[](size_t i) const
Coordinate access using operator[].
static constexpr unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D.
bool getPolygon(TPolygon2D &p) const
Gets the content as a polygon, returning false if the type is inadequate.
double norm() const
Returns the norm of the (x,y) vector (phi is not used)
void rotate(const double ang)
Transform the (vx,vy) components for a counterclockwise rotation of ang radians.
TPoint2D & operator*=(double d)
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04]" ) ...
constexpr const double & operator[](size_t i) const
Coordinate access using operator[].
static void SO3_to_yaw_pitch_roll(const mrpt::math::CMatrixDouble33 &R, double &yaw, double &pitch, double &roll)
constexpr TPointXYZIu8(double x, double y, double z, uint8_t intensity_val)
unsigned char getType() const
Gets content type.
bool isPolygon() const
Checks whether content is a polygon.
void destroy()
Destroys the object and releases the pointer, if any.
constexpr TPoint3D operator-(const TPoint3D &p) const
Points substraction.
bool operator==(const TTwist3D &o) const
void getRotationMatrix(mrpt::math::CMatrixDouble33 &R) const
#define THROW_EXCEPTION(msg)
double distance(const TPoint3D &point) const
Distance between the line and a point.
T hypot_fast(const T x, const T y)
Faster version of std::hypot(), to use when overflow is not an issue and we prefer fast code...
constexpr TPointXYZfIu8(float x, float y, float z, uint8_t intensity_val)
void getPlotData(std::vector< double > &x, std::vector< double > &y) const
Gets plot data, ready to use on a 2D plot.
TObject2D(const TPoint2D &p)
Implicit constructor from point.
bool isSkew() const
Check whether the polygon is skew.
TLine2D()
Fast default constructor.
bool getSegment(TSegment3D &s) const
Gets the content as a segment, returning false if the type is not adequate.
bool contains(const TPoint2D &point) const
Check whether a point is inside a segment.
void normalizePhi()
Forces "phi" to be in the range [-pi,pi].
bool contains(const TSegment3D &segment) const
Check whether a segment is fully contained into the plane.
constexpr const double & operator[](size_t i) const
Coordinate access using operator[].
double roll
Roll coordinate (rotation angle over X coordinate).
void getAsPose3D(mrpt::math::TPose3D &outPose)
static void getPolygons(const std::vector< TObject2D > &objs, std::vector< TPolygon2D > &polys)
Static method to retrieve all the polygons in a vector of TObject2D.
TPolygon3D()
Default constructor.
Base type of all TPoseXX and TPointXX classes in mrpt::math.
GLdouble GLdouble GLdouble GLdouble q
constexpr const TPoint2D & operator[](size_t i) const
Access to points using operator[0-1].
double distance(const TPoint2D &point) const
Distance to point.
static void getLines(const std::vector< TObject2D > &objs, std::vector< TLine2D > &lins)
Static method to retrieve all the lines in a vector of TObject2D.
void operator=(const TPoint2D &p)
Assign a point to this object.
constexpr TPoint2D operator/(double d) const
double norm() const
Point norm.
constexpr TPoint2D operator-(const TPoint2D &p) const
constexpr const double & operator[](size_t i) const
Coordinate access using operator[].
void operator=(const TSegment2D &s)
Assign a segment to this object.
mrpt::math::TPoint2D composePoint(const TPoint2D l) const
std::string asString() const
Union containing pointer to actual data.
TTwist3D()
Default fast constructor.
void getAsQuaternion(mrpt::math::CQuaternion< double > &q, mrpt::math::CMatrixFixedNumeric< double, 4, 3 > *out_dq_dr=NULL) const
Returns the quaternion associated to the rotation of this object (NOTE: XYZ translation is ignored) ...
TPoint3D()
Default fast constructor.
double signedDistance(const TPoint2D &point) const
Distance with sign from a given point (sign indicates side).
TPoint3Df & operator+=(const TPoint3Df &p)
Standard type for storing any lightweight 2D type.
TLine3D()
Fast default constructor.
bool getLine(TLine2D &r) const
Gets the content as a line, returning false if the type is inadequate.
TObject2D()
Implicit constructor from polygon.
void getAsSegmentList(std::vector< TSegment2D > &v) const
Gets as set of segments, instead of points.
constexpr TPoint2D operator+(const TPoint2D &p) const
bool getPlane(TPlane &p) const
Gets the content as a plane, returning false if the type is not adequate.
TPoint3D pBase
Base point.
Standard object for storing any 3D lightweight object.
bool getSegment(TSegment2D &s) const
Gets the content as a segment, returning false if the type is inadequate.
bool contains(const TPoint2D &point) const
Check whether a point is inside the line.
TSegment3D()
Fast default constructor.
void removeRepeatedVertices()
Erase repeated vertices.
double signedDistance(const TPoint2D &point) const
Distance with sign to point (sign indicates which side the point is).
void getInverseHomogeneousMatrix(mrpt::math::CMatrixDouble44 &HG) const
void generate3DObject(TLine3D &l) const
Project into 3D space, setting the z to 0.
TObject3D()
Empty constructor.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45...
void getAsPose2D(TPose2D &outPose) const
double distance(const TPoint3D &point) const
Distance to 3D point.
TPoint3D & operator+=(const TPoint3D &p)
Translation.
double yaw
Yaw coordinate (rotation angle over Z axis).
constexpr TPointXYZRGBu8(double x, double y, double z, uint8_t R_val, uint8_t G_val, uint8_t B_val)
void operator=(const TSegment3D &s)
Assigns a segment to this object.
void composePoint(const TPoint3D l, TPoint3D &g) const
void operator=(const TPoint3D &p)
Assigns a point to this object.
TPose2D(double xx, double yy, double pphi)
Constructor from coordinates.
GLsizei GLsizei GLuint * obj
constexpr TTwist3D(double vx_, double vy_, double vz_, double wx_, double wy_, double wz_)
Constructor from components.
TSegment3D(const TSegment2D &s)
Constructor from 2D object.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[vx vy vz wx wy wz]" ) ...
double & operator[](size_t i)
Coordinate access using operator[].
constexpr TLine2D(double A, double B, double C)
Constructor from line's coefficients.
static constexpr size_t size()
double norm() const
Pose's spatial coordinates norm.
bool operator<(const TSegment3D &s) const
void getUnitaryDirectorVector(double(&vector)[2])
Unitarize line and then get director vector.
double & operator[](size_t i)
Coordinate access using operator[].
3D twist: 3D velocity vector (vx,vy,vz) + angular velocity (wx,wy,wz)
TObject3D(const TPlane &p)
Constructor from plane.
TPoint3D point1
Origin point.
void getUnitaryDirectorVector(double(&vector)[3])
Unitarize and then get director vector.
static void getSegments(const std::vector< TObject3D > &objs, std::vector< TSegment3D > &sgms)
Static method to retrieve every segment included in a vector of objects.
static constexpr unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D.
void generate2DObject(TLine2D &l) const
Project into 2D space, discarding the Z coordinate.
TPose3D()
Default fast constructor.
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
T square(const T x)
Inline function for the square of a number.
void getNormalVector(double(&vector)[2]) const
Get line's normal vector.
void generate3DObject(TPolygon3D &p) const
Projects into 3D space, zeroing the z.
bool contains(const TPoint3D &point) const
Check whether a point is inside the line.
void unitarize()
Unitarize line's normal vector.
std::string asString() const
void getBoundingBox(TPoint2D &min_coords, TPoint2D &max_coords) const
Get polygon bounding box.
A numeric matrix of compile-time fixed size.
bool getPolygon(TPolygon3D &p) const
Gets the content as a polygon, returning false if the type is not adequate.
This base provides a set of functions for maths stuff.
static constexpr unsigned char GEOMETRIC_TYPE_UNDEFINED
Object type identifier for empty TObject2D or TObject3D.
2D segment, consisting of two points.
bool isPoint() const
Checks whether content is a point.
double distance(const TPoint3D &point) const
Distance to point.
struct mrpt::math::TObject2D::tobject2d_data_t data
TPlane(const double(&vec)[4])
Constructor from an array of coefficients.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45...
3D segment, consisting of two points.
double length() const
Segment length.
TObject2D(const TLine2D &r)
Implicit constructor from line.
Lightweight 3D point (float version).
void fromHomogeneousMatrix(const mrpt::math::CMatrixDouble44 &HG)
constexpr bool operator==(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
constexpr TPoint2D(double xx, double yy)
Constructor from coordinates.
TObject3D(const TPoint3D &p)
Constructor from point.
TPoint3D point2
Destiny point.
constexpr const double & operator[](size_t i) const
Coordinate access using operator[].
bool operator<(const TSegment2D &s) const
float & operator[](size_t i)
Coordinate access using operator[].
std::string asString() const
std::ostream & operator<<(std::ostream &o, const TPoint2D &p)
constexpr const float & operator[](size_t i) const
Coordinate access using operator[].
double vx
Velocity components: X,Y (m/s)
constexpr const double & operator[](size_t i) const
Coordinate access using operator[].
double distanceTo(const TPoint3D &p) const
Point-to-point distance.
TObject3D & operator=(const TObject3D &obj)
Assigns another object, creating a new pointer if needed.
constexpr TPoint3D operator+(const TPoint3D &p) const
Points addition.
mrpt::math::TPose2D operator+(const mrpt::math::TPose2D &b) const
Operator "oplus" pose composition: "ret=this \oplus b".
mrpt::math::TPoint2D inverseComposePoint(const TPoint2D g) const
static void getLines(const std::vector< TObject3D > &objs, std::vector< TLine3D > &lins)
Static method to retrieve every line included in a vector of objects.
void unitarize()
Unitarize normal vector.
mrpt::math::TPose2D operator*(const double dt) const
Returns the pose increment of multiplying each twist component times "dt" seconds.
double x
Translation in x,y,z.
const TPoint3D & operator[](size_t i) const
Access to points using operator[0-1].
XYZ point (float) + RGB(u8)
T wrapTo2Pi(T a)
Modifies the given angle to translate it into the [0,2pi[ range.
void generate2DObject(TPolygon2D &p) const
Projects into a 2D space, discarding the z.
static void getPolygons(const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys)
Static method to retrieve every polygon included in a vector of objects.
3D Plane, represented by its equation
void getDirectorVector(double(&vector)[3]) const
Get director vector.
bool getPlane(TPlane &p) const
Gets a plane which contains the polygon.
constexpr TPlane(double A, double B, double C, double D)
Constructor from plane coefficients.
double coefs[3]
Line coefficients, stored as an array: .
TPolygon2D()
Default constructor.
double x
X,Y,Z coordinates.
void operator=(const TPolygon3D &p)
Assigns a polygon to this object.
void removeRedundantVertices()
Erase every redundant vertex, thus saving space.
#define MRPT_DECLARE_TTYPENAME_NO_NAMESPACE(_TYPE, __NS)
Declares a typename to be "type" (without the NS prefix)
void getCenter(TPoint3D &p) const
Segment's central point.
unsigned char type
Object type identifier.
TPose3DQuat()
Default fast constructor.
TPoint2D point2
Destiny point.
bool isSegment() const
Checks whether content is a segment.
XYZ point (float) + Intensity(u8)
void inverseComposePoint(const TPoint3D g, TPoint3D &l) const
TObject2D(const TObject2D &obj)
Constructor from another TObject2D.
TPoint2D & operator[](size_t i)
Access to points using operator[0-1].
void getCenter(TPoint2D &p) const
Polygon's central point.
void getAsVector(std::vector< double > &v) const
Gets the pose as a vector of doubles.
void rotate(const mrpt::math::TPose3D &rot)
Transform all 6 components for a change of reference frame from "A" to another frame "B" whose rotati...
TObject2D & operator=(const TObject2D &obj)
Assign another TObject2D.
bool isPlane() const
Checks whether content is a plane.
GLsizei const GLchar ** string
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
double qr
Unit quaternion part, qr,qx,qy,qz.
constexpr TPose3D(double _x, double _y, double _z, double _yaw, double _pitch, double _roll)
Constructor from coordinates.
void unitarize()
Unitarize director vector.
void operator=(const TPlane &p)
Assigns a plane to this object.
TObject2D(const TSegment2D &s)
Implicit constructor from segment.
TPolygon2D(size_t N)
Constructor for a given number of vertices, intializing them as garbage.
bool contains(const TPoint3D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
constexpr TTwist2D(double vx_, double vy_, double omega_)
Constructor from components.
double & operator[](size_t i)
Coordinate access using operator[].
bool getPoint(TPoint3D &p) const
Gets the content as a point, returning false if the type is not adequate.
double pitch
Pitch coordinate (rotation angle over Y axis).
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
double distance(const TPoint3D &point) const
Distance to point (always >=0)
double director[3]
Director vector.
TPoint2D point1
Origin point.
double norm() const
Point norm.
bool isConvex() const
Checks whether is convex.
TPoint2D()
Default fast constructor.
static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &HG) const
mrpt::math::TPoint2D operator+(const mrpt::math::TPoint2D &b) const
void generate3DObject(TSegment3D &s) const
Project into 3D space, setting the z to 0.
bool contains(const TPoint2D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
TPoint3D & operator*=(const double f)
Point scale.
double distance(const TPoint2D &point) const
Distance to a point (always >=0)
TObject3D(const TLine3D &r)
Constructor from line.
bool isLine() const
Checks whether content is a line.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void getAsPose2DForcingOrigin(const TPoint2D &origin, TPose2D &outPose) const
TPlane()
Fast default constructor.
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04 -0.8]" )
double wx
Angular velocity (rad/s)
Virtual base class for "archives": classes abstracting I/O streams.
std::string asString() const
GLdouble GLdouble GLdouble r
double vx
Velocity components: X,Y (m/s)
void getAsPose3DForcingOrigin(const TPoint3D &newOrigin, TPose3D &pose)
void generate3DObject(TObject3D &obj) const
Project into 3D space.
void operator=(const TPolygon2D &p)
Assign a polygon to this object.
constexpr TPoint3D(double xx, double yy, double zz)
Constructor from coordinates.
XYZ point (double) + RGB(u8)
double sqrDistanceTo(const TPoint3D &p) const
Point-to-point distance, squared.
static void getPoints(const std::vector< TObject2D > &objs, std::vector< TPoint2D > &pnts)
Static method to retrieve all the points in a vector of TObject2D.
void getUnitaryNormalVector(double(&vec)[3])
Unitarize, then get normal vector.
double norm() const
Pose's spatial coordinates norm.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double coefs[4]
Plane coefficients, stored as an array: .
TSegment2D()
Fast default constructor.
unsigned char type
Object type identifier.
~TObject2D()
Object destruction.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0...
struct mrpt::math::TObject3D::tobject3d_data_t data
bool operator!=(const TTwist3D &o) const
TPoint3D & operator[](size_t i)
Access to points using operator[0-1].
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
constexpr TPoint3D operator/(double d) const
void removeRedundantVertices()
Erase every redundant vertex from the polygon, saving space.
void removeRepeatedVertices()
Remove polygon's repeated vertices.
bool contains(const TPoint3D &point) const
Check whether a point is inside the segment.
bool getLine(TLine3D &r) const
Gets the content as a line, returning false if the type is not adequate.
void getAsVector(std::vector< double > &v) const
Transformation into vector.
double evaluatePoint(const TPoint3D &point) const
Evaluate a point in the plane's equation.
std::string asString() const
void generate2DObject(TSegment2D &s) const
Projection into 2D space, discarding the z.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0...
void generate2DObject(TObject2D &obj) const
Projects into 2D space.
bool isLine() const
Checks whether content is a line.
bool operator<(const TPoint3D &p) const
constexpr bool operator!=(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
double evaluatePoint(const TPoint2D &point) const
Evaluate point in the line's equation.
bool isSegment() const
Checks whether content is a segment.
TObject2D(const TPolygon2D &p)
Implicit constructor from polygon.
TSegment3D(const TPoint3D &p1, const TPoint3D &p2)
Constructor from both points.
TObject3D(const TObject3D &obj)
Constructs from another object.
TPose2D()
Default fast constructor.
constexpr const double & operator[](size_t i) const
Coordinate access using operator[].
GLsizei const GLfloat * value
unsigned char getType() const
Gets object type.
TPoint2D & operator-=(const TPoint2D &p)
mrpt::math::TPose2D operator-(const mrpt::math::TPose2D &b) const
Operator "ominus" pose composition: "ret=this \ominus b".
void operator=(const TLine3D &l)
Assigns a line to this object.
double & operator[](size_t i)
Coordinate access using operator[].
constexpr TPoint3Df(const float xx, const float yy, const float zz)
static constexpr unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
void getAsVector(std::vector< double > &v) const
Transformation into vector.
TPolygon3D(size_t N)
Constructor for a given size.
void asString(std::string &s) const
Returns a human-readable textual representation of the object as "[x y z qr qx qy qz]"...
void operator=(const TLine2D &l)
Assign a line to this object.
double distance(const TPoint2D &point) const
Distance from a given point.
void getAsSegmentList(std::vector< TSegment3D > &v) const
Gets as set of segments, instead of set of points.
bool isPolygon() const
Checks whether content is a polygon.
void getBestFittingPlane(TPlane &p) const
Gets the best fitting plane, disregarding whether the polygon actually fits inside or not...
constexpr TPoint3D operator*(double d) const
void getDirectorVector(double(&vector)[2]) const
Get line's director vector.
void destroy()
Destroys the object, releasing the pointer to the content (if any).
TObject3D(const TSegment3D &s)
Constructor from segment.
std::string asString() const
TTwist2D()
Default fast constructor.
constexpr TPointXYZfRGBu8(float x, float y, float z, uint8_t R_val, uint8_t G_val, uint8_t B_val)
XYZ point (double) + Intensity(u8)
GLsizei GLsizei GLenum GLenum const GLvoid * data
std::string asString() const
GLubyte GLubyte GLubyte a
void getAsVector(std::vector< double > &v) const
Gets the pose as a vector of doubles.
void getAsVector(std::vector< double > &v) const
Transformation into vector.
TPose3D operator-(const TPose3D &p)
Unary $$ operator: computes inverse SE(3) element.
static void getPlanes(const std::vector< TObject3D > &objs, std::vector< TPlane > &plns)
Static method to retrieve every plane included in a vector of objects.
constexpr TPoint2D operator*(double d) const
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrix::Ptr &pObj)
TObject3D(const TPolygon3D &p)
Constructor from polygon.
double phi
Orientation (rads)
bool operator<(const TPoint2D &p) const
GLuint GLuint GLsizei GLenum type
static constexpr unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane.
double & operator[](size_t i)
Coordinate access using operator[].
void getAsVector(VECTORLIKE &v) const
Transformation into vector.
2D polygon, inheriting from std::vector<TPoint2D>.
TPoint3D & operator-=(const TPoint3D &p)
Difference between points.
3D polygon, inheriting from std::vector<TPoint3D>
Union type storing pointers to every allowed type.
void getCenter(TPoint3D &p) const
Get polygon's central point.
double omega
Angular velocity (rad/s)
bool contains(const TPoint3D &point) const
Check whether a point is contained into the plane.
double length() const
Segment length.
void getAsVector(std::vector< double > &v) const
Transformation into vector.
double & operator[](size_t i)
Coordinate access using operator[].
TPoint3D(const TPoint3Df &p)
Explicit constructor from coordinates.
bool isPoint() const
Checks whether content is a point.
bool operator!=(const TTwist2D &o) const
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0...
bool operator==(const TTwist2D &o) const
TPoint2D & operator/=(double d)
TPoint3Df operator*(const float s)
void getNormalVector(double(&vec)[3]) const
Get plane's normal vector.
3D line, represented by a base point and a director vector.
void composePose(const TPose3D other, TPose3D &result) const
TPolygon2D(const std::vector< TPoint2D > &v)
Implicit constructor from a vector of 2D points.
2D line without bounds, represented by its equation .
static void getPoints(const std::vector< TObject3D > &objs, std::vector< TPoint3D > &pnts)
Static method to retrieve every point included in a vector of objects.