Main MRPT website > C++ reference
MRPT logo
Classes | Typedefs | Functions | Variables
Geometry: lines, planes, intersections, SLERP, "lightweight" point & pose classes

Detailed Description

Collaboration diagram for Geometry: lines, planes, intersections, SLERP, "lightweight" point & pose classes:

Classes

class  mrpt::math::CPolygon
 A wrapper of a TPolygon2D class, implementing CSerializable. More...
 
class  mrpt::math::TPolygonWithPlane
 Slightly heavyweight type to speed-up calculations with polygons in 3D. More...
 
struct  mrpt::math::TPoint2D
 Lightweight 2D point. More...
 
struct  mrpt::math::TPose2D
 Lightweight 2D pose. More...
 
struct  mrpt::math::TPoint3Df
 Lightweight 3D point (float version). More...
 
struct  mrpt::math::TPoint3D
 Lightweight 3D point. More...
 
struct  mrpt::math::TPose3D
 Lightweight 3D pose (three spatial coordinates, plus three angular coordinates). More...
 
struct  mrpt::math::TPose3DQuat
 Lightweight 3D pose (three spatial coordinates, plus a quaternion ). More...
 
struct  mrpt::math::TSegment2D
 2D segment, consisting of two points. More...
 
struct  mrpt::math::TSegment3D
 3D segment, consisting of two points. More...
 
struct  mrpt::math::TLine2D
 2D line without bounds, represented by its equation $Ax+By+C=0$. More...
 
struct  mrpt::math::TLine3D
 3D line, represented by a base point and a director vector. More...
 
struct  mrpt::math::TPlane
 3D Plane, represented by its equation $Ax+By+Cz+D=0$ More...
 
class  mrpt::math::TPolygon2D
 2D polygon, inheriting from std::vector<TPoint2D>. More...
 
class  mrpt::math::TPolygon3D
 3D polygon, inheriting from std::vector<TPoint3D> More...
 
struct  mrpt::math::TObject2D
 Standard type for storing any lightweight 2D type. More...
 
struct  mrpt::math::TObject3D
 Standard object for storing any 3D lightweight object. More...
 

Typedefs

typedef TPlane mrpt::math::TPlane3D
 

Functions

std::ostream BASE_IMPEXPmrpt::math::operator<< (std::ostream &o, const TPoint2D &p)
 
std::ostream BASE_IMPEXPmrpt::math::operator<< (std::ostream &o, const TPoint3D &p)
 
std::ostream BASE_IMPEXPmrpt::math::operator<< (std::ostream &o, const TPose2D &p)
 
std::ostream BASE_IMPEXPmrpt::math::operator<< (std::ostream &o, const TPose3D &p)
 
std::ostream BASE_IMPEXPmrpt::math::operator<< (std::ostream &o, const TPose3DQuat &p)
 
TPoint3D mrpt::math::operator- (const TPoint3D &p1)
 Unary minus operator for 3D points.
 
bool mrpt::math::operator== (const TPoint2D &p1, const TPoint2D &p2)
 Exact comparison between 2D points.
 
bool mrpt::math::operator!= (const TPoint2D &p1, const TPoint2D &p2)
 Exact comparison between 2D points.
 
bool mrpt::math::operator== (const TPoint3D &p1, const TPoint3D &p2)
 Exact comparison between 3D points.
 
bool mrpt::math::operator!= (const TPoint3D &p1, const TPoint3D &p2)
 Exact comparison between 3D points.
 
bool mrpt::math::operator== (const TPose2D &p1, const TPose2D &p2)
 Exact comparison between 2D poses, taking possible cycles into account.
 
bool mrpt::math::operator!= (const TPose2D &p1, const TPose2D &p2)
 Exact comparison between 2D poses, taking possible cycles into account.
 
bool mrpt::math::operator== (const TPose3D &p1, const TPose3D &p2)
 Exact comparison between 3D poses, taking possible cycles into account.
 
bool mrpt::math::operator!= (const TPose3D &p1, const TPose3D &p2)
 Exact comparison between 3D poses, taking possible cycles into account.
 
bool mrpt::math::operator== (const TSegment2D &s1, const TSegment2D &s2)
 
bool mrpt::math::operator!= (const TSegment2D &s1, const TSegment2D &s2)
 
bool mrpt::math::operator== (const TSegment3D &s1, const TSegment3D &s2)
 
bool mrpt::math::operator!= (const TSegment3D &s1, const TSegment3D &s2)
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TPoint2D &o)
 TPoint2D binary input.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TPoint2D &o)
 TPoint2D binary output.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TPoint3D &o)
 TPoint3D binary input.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TPoint3D &o)
 TPoint3D binary output.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TPose2D &o)
 TPose2D binary input.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TPose2D &o)
 TPose2D binary output.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TPose3D &o)
 TPose3D binary input.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TPose3D &o)
 TPose3D binary output.
 
mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TSegment2D &s)
 TSegment2D binary input.
 
mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TSegment2D &s)
 TSegment2D binary output.
 
mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TLine2D &l)
 TLine2D binary input.
 
mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TLine2D &l)
 TLine2D binary output.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TObject2D &o)
 TObject2D binary input.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TObject2D &o)
 TObject2D binary input.
 
mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TSegment3D &s)
 TSegment3D binary input.
 
mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TSegment3D &s)
 TSegment3D binary output.
 
mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TLine3D &l)
 TLine3D binary input.
 
mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TLine3D &l)
 TLine3D binary output.
 
mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TPlane &p)
 TPlane binary input.
 
mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TPlane &p)
 TPlane binary output.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, mrpt::math::TObject3D &o)
 TObject3D binary input.
 
BASE_IMPEXP mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const mrpt::math::TObject3D &o)
 TObject3D binary output.
 

Variables

double BASE_IMPEXP mrpt::math::geometryEpsilon
 Global epsilon to overcome small precision errors.
 
struct BASE_IMPEXP mrpt::math::TSegment3D
 
struct BASE_IMPEXP mrpt::math::TLine3D
 
class BASE_IMPEXP mrpt::math::TPolygon3D
 
struct BASE_IMPEXP mrpt::math::TObject3D
 
const unsigned char mrpt::math::GEOMETRIC_TYPE_POINT =0
 Object type identifier for TPoint2D or TPoint3D.
 
const unsigned char mrpt::math::GEOMETRIC_TYPE_SEGMENT =1
 Object type identifier for TSegment2D or TSegment3D.
 
const unsigned char mrpt::math::GEOMETRIC_TYPE_LINE =2
 Object type identifier for TLine2D or TLine3D.
 
const unsigned char mrpt::math::GEOMETRIC_TYPE_POLYGON =3
 Object type identifier for TPolygon2D or TPolygon3D.
 
const unsigned char mrpt::math::GEOMETRIC_TYPE_PLANE =4
 Object type identifier for TPlane.
 
const unsigned char mrpt::math::GEOMETRIC_TYPE_UNDEFINED =255
 Object type identifier for empty TObject2D or TObject3D.
 

Simple intersection operations, relying basically on geometrical operations.

bool BASE_IMPEXP mrpt::math::intersect (const TSegment3D &s1, const TSegment3D &s2, TObject3D &obj)
 Gets the intersection between two 3D segments.
 
bool BASE_IMPEXP mrpt::math::intersect (const TSegment3D &s1, const TPlane &p2, TObject3D &obj)
 Gets the intersection between a 3D segment and a plane.
 
bool BASE_IMPEXP mrpt::math::intersect (const TSegment3D &s1, const TLine3D &r2, TObject3D &obj)
 Gets the intersection between a 3D segment and a 3D line.
 
bool mrpt::math::intersect (const TPlane &p1, const TSegment3D &s2, TObject3D &obj)
 Gets the intersection between a plane and a 3D segment.
 
bool BASE_IMPEXP mrpt::math::intersect (const TPlane &p1, const TPlane &p2, TObject3D &obj)
 Gets the intersection between two planes.
 
bool BASE_IMPEXP mrpt::math::intersect (const TPlane &p1, const TLine3D &p2, TObject3D &obj)
 Gets the intersection between a plane and a 3D line.
 
bool mrpt::math::intersect (const TLine3D &r1, const TSegment3D &s2, TObject3D &obj)
 Gets the intersection between a 3D line and a 3D segment.
 
bool mrpt::math::intersect (const TLine3D &r1, const TPlane &p2, TObject3D &obj)
 Gets the intersection between a 3D line and a plane.
 
bool BASE_IMPEXP mrpt::math::intersect (const TLine3D &r1, const TLine3D &r2, TObject3D &obj)
 Gets the intersection between two 3D lines.
 
bool BASE_IMPEXP mrpt::math::intersect (const TLine2D &r1, const TLine2D &r2, TObject2D &obj)
 Gets the intersection between two 2D lines.
 
bool BASE_IMPEXP mrpt::math::intersect (const TLine2D &r1, const TSegment2D &s2, TObject2D &obj)
 Gets the intersection between a 2D line and a 2D segment.
 
bool mrpt::math::intersect (const TSegment2D &s1, const TLine2D &r2, TObject2D &obj)
 Gets the intersection between a 2D line and a 2D segment.
 
bool BASE_IMPEXP mrpt::math::intersect (const TSegment2D &s1, const TSegment2D &s2, TObject2D &obj)
 Gets the intersection between two 2D segments.
 

Angle retrieval methods. Methods which use TSegments will automatically use TLines' implicit constructors.

double BASE_IMPEXP mrpt::math::getAngle (const TPlane &p1, const TPlane &p2)
 Computes the angle between two planes.
 
double BASE_IMPEXP mrpt::math::getAngle (const TPlane &p1, const TLine3D &r2)
 Computes the angle between a plane and a 3D line or segment (implicit constructor will be used if passing a segment instead of a line).
 
double mrpt::math::getAngle (const TLine3D &r1, const TPlane &p2)
 Computes the angle between a 3D line or segment and a plane (implicit constructor will be used if passing a segment instead of a line).
 
double BASE_IMPEXP mrpt::math::getAngle (const TLine3D &r1, const TLine3D &r2)
 Computes the angle between two 3D lines or segments (implicit constructor will be used if passing a segment instead of a line).
 
double BASE_IMPEXP mrpt::math::getAngle (const TLine2D &r1, const TLine2D &r2)
 Computes the angle between two 2D lines or segments (implicit constructor will be used if passing a segment instead of a line).
 

Creation of lines from poses.

void BASE_IMPEXP mrpt::math::createFromPoseX (const CPose3D &p, TLine3D &r)
 Gets a 3D line corresponding to the X axis in a given pose.
 
void BASE_IMPEXP mrpt::math::createFromPoseY (const CPose3D &p, TLine3D &r)
 Gets a 3D line corresponding to the Y axis in a given pose.
 
void BASE_IMPEXP mrpt::math::createFromPoseZ (const CPose3D &p, TLine3D &r)
 Gets a 3D line corresponding to the Z axis in a given pose.
 
void BASE_IMPEXP mrpt::math::createFromPoseAndVector (const CPose3D &p, const double(&vector)[3], TLine3D &r)
 Gets a 3D line corresponding to any arbitrary vector, in the base given by the pose.
 
void BASE_IMPEXP mrpt::math::createFromPoseX (const TPose2D &p, TLine2D &r)
 Gets a 2D line corresponding to the X axis in a given pose.
 
void BASE_IMPEXP mrpt::math::createFromPoseY (const TPose2D &p, TLine2D &r)
 Gets a 2D line corresponding to the Y axis in a given pose.
 
void BASE_IMPEXP mrpt::math::createFromPoseAndVector (const TPose2D &p, const double(&vector)[2], TLine2D &r)
 Gets a 2D line corresponding to any arbitrary vector, in the base given the given pose.
 

Other line or plane related methods.

bool BASE_IMPEXP mrpt::math::conformAPlane (const std::vector< TPoint3D > &points)
 Checks whether this polygon or set of points acceptably fits a plane.
 
bool BASE_IMPEXP mrpt::math::conformAPlane (const std::vector< TPoint3D > &points, TPlane &p)
 Checks whether this polygon or set of points acceptably fits a plane, and if it's the case returns it in the second argument.
 
bool BASE_IMPEXP mrpt::math::areAligned (const std::vector< TPoint2D > &points)
 Checks whether this set of points acceptably fits a 2D line.
 
bool BASE_IMPEXP mrpt::math::areAligned (const std::vector< TPoint2D > &points, TLine2D &r)
 Checks whether this set of points acceptably fits a 2D line, and if it's the case returns it in the second argument.
 
bool BASE_IMPEXP mrpt::math::areAligned (const std::vector< TPoint3D > &points)
 Checks whether this set of points acceptably fits a 3D line.
 
bool BASE_IMPEXP mrpt::math::areAligned (const std::vector< TPoint3D > &points, TLine3D &r)
 Checks whether this set of points acceptably fits a 3D line, and if it's the case returns it in the second argument.
 

Projections

void mrpt::math::project3D (const TPoint3D &point, const CPose3D &newXYpose, TPoint3D &newPoint)
 Uses the given pose 3D to project a point into a new base.
 
void mrpt::math::project3D (const TSegment3D &segment, const CPose3D &newXYpose, TSegment3D &newSegment)
 Uses the given pose 3D to project a segment into a new base.
 
void BASE_IMPEXP mrpt::math::project3D (const TLine3D &line, const CPose3D &newXYpose, TLine3D &newLine)
 Uses the given pose 3D to project a line into a new base.
 
void BASE_IMPEXP mrpt::math::project3D (const TPlane &plane, const CPose3D &newXYpose, TPlane &newPlane)
 Uses the given pose 3D to project a plane into a new base.
 
void BASE_IMPEXP mrpt::math::project3D (const TPolygon3D &polygon, const CPose3D &newXYpose, TPolygon3D &newPolygon)
 Uses the given pose 3D to project a polygon into a new base.
 
void BASE_IMPEXP mrpt::math::project3D (const TObject3D &object, const CPose3D &newXYPose, TObject3D &newObject)
 Uses the given pose 3D to project any 3D object into a new base.
 
template<class T >
void mrpt::math::project3D (const T &obj, const TPlane &newXYPlane, T &newObj)
 Projects any 3D object into the plane's base, using its inverse pose.
 
template<class T >
void mrpt::math::project3D (const T &obj, const TPlane &newXYPlane, const TPoint3D &newOrigin, T &newObj)
 Projects any 3D object into the plane's base, using its inverse pose and forcing the position of the new coordinates origin.
 
template<class T >
void mrpt::math::project3D (const std::vector< T > &objs, const CPose3D &newXYpose, std::vector< T > &newObjs)
 Projects a set of 3D objects into the plane's base.
 
void mrpt::math::project2D (const TPoint2D &point, const CPose2D &newXpose, TPoint2D &newPoint)
 Uses the given pose 2D to project a point into a new base.
 
void mrpt::math::project2D (const TSegment2D &segment, const CPose2D &newXpose, TSegment2D &newSegment)
 Uses the given pose 2D to project a segment into a new base.
 
void BASE_IMPEXP mrpt::math::project2D (const TLine2D &line, const CPose2D &newXpose, TLine2D &newLine)
 Uses the given pose 2D to project a line into a new base.
 
void BASE_IMPEXP mrpt::math::project2D (const TPolygon2D &polygon, const CPose2D &newXpose, TPolygon2D &newPolygon)
 Uses the given pose 2D to project a polygon into a new base.
 
void BASE_IMPEXP mrpt::math::project2D (const TObject2D &object, const CPose2D &newXpose, TObject2D &newObject)
 Uses the given pose 2D to project any 2D object into a new base.
 
template<class T >
void mrpt::math::project2D (const T &obj, const TLine2D &newXLine, T &newObj)
 Projects any 2D object into the line's base, using its inverse pose.
 
template<class T >
void mrpt::math::project2D (const T &obj, const TLine2D &newXLine, const TPoint2D &newOrigin, T &newObj)
 Projects any 2D object into the line's base, using its inverse pose and forcing the position of the new coordinate origin.
 
template<class T >
void mrpt::math::project2D (const std::vector< T > &objs, const CPose2D &newXpose, std::vector< T > &newObjs)
 Projects a set of 2D objects into the line's base.
 

Polygon intersections. These operations rely more on spatial reasoning than in raw numerical operations.

bool BASE_IMPEXP mrpt::math::intersect (const TPolygon2D &p1, const TSegment2D &s2, TObject2D &obj)
 Gets the intersection between a 2D polygon and a 2D segment.
 
bool BASE_IMPEXP mrpt::math::intersect (const TPolygon2D &p1, const TLine2D &r2, TObject2D &obj)
 Gets the intersection between a 2D polygon and a 2D line.
 
bool BASE_IMPEXP mrpt::math::intersect (const TPolygon2D &p1, const TPolygon2D &p2, TObject2D &obj)
 Gets the intersection between two 2D polygons.
 
bool mrpt::math::intersect (const TSegment2D &s1, const TPolygon2D &p2, TObject2D &obj)
 Gets the intersection between a 2D segment and a 2D polygon.
 
bool mrpt::math::intersect (const TLine2D &r1, const TPolygon2D &p2, TObject2D &obj)
 Gets the intersection between a 2D line and a 2D polygon.
 
bool BASE_IMPEXP mrpt::math::intersect (const TPolygon3D &p1, const TSegment3D &s2, TObject3D &obj)
 Gets the intersection between a 3D polygon and a 3D segment.
 
bool BASE_IMPEXP mrpt::math::intersect (const TPolygon3D &p1, const TLine3D &r2, TObject3D &obj)
 Gets the intersection between a 3D polygon and a 3D line.
 
bool BASE_IMPEXP mrpt::math::intersect (const TPolygon3D &p1, const TPlane &p2, TObject3D &obj)
 Gets the intersection between a 3D polygon and a plane.
 
bool BASE_IMPEXP mrpt::math::intersect (const TPolygon3D &p1, const TPolygon3D &p2, TObject3D &obj)
 Gets the intersection between two 3D polygons.
 
bool mrpt::math::intersect (const TSegment3D &s1, const TPolygon3D &p2, TObject3D &obj)
 Gets the intersection between a 3D segment and a 3D polygon.
 
bool mrpt::math::intersect (const TLine3D &r1, const TPolygon3D &p2, TObject3D &obj)
 Gets the intersection between a 3D line and a 3D polygon.
 
bool mrpt::math::intersect (const TPlane &p1, const TPolygon3D &p2, TObject3D &obj)
 Gets the intersection between a plane and a 3D polygon.
 
size_t BASE_IMPEXP mrpt::math::intersect (const std::vector< TPolygon3D > &v1, const std::vector< TPolygon3D > &v2, CSparseMatrixTemplate< TObject3D > &objs)
 Gets the intersection between two sets of 3D polygons.
 
size_t BASE_IMPEXP mrpt::math::intersect (const std::vector< TPolygon3D > &v1, const std::vector< TPolygon3D > &v2, std::vector< TObject3D > &objs)
 Gets the intersection between two sets of 3D polygons.
 

Other intersections

template<class T , class U , class O >
size_t mrpt::math::intersect (const std::vector< T > &v1, const std::vector< U > &v2, CSparseMatrixTemplate< O > &objs)
 Gets the intersection between vectors of geometric objects and returns it in a sparse matrix of either TObject2D or TObject3D.
 
template<class T , class U , class O >
size_t mrpt::math::intersect (const std::vector< T > &v1, const std::vector< U > &v2, std::vector< O > objs)
 Gets the intersection between vectors of geometric objects and returns it in a vector of either TObject2D or TObject3D.
 
bool BASE_IMPEXP mrpt::math::intersect (const TObject2D &o1, const TObject2D &o2, TObject2D &obj)
 Gets the intersection between any pair of 2D objects.
 
bool BASE_IMPEXP mrpt::math::intersect (const TObject3D &o1, const TObject3D &o2, TObject3D &obj)
 Gets the intersection between any pair of 3D objects.
 

Distances

double BASE_IMPEXP mrpt::math::distance (const TPoint2D &p1, const TPoint2D &p2)
 Gets the distance between two points in a 2D space.
 
double BASE_IMPEXP mrpt::math::distance (const TPoint3D &p1, const TPoint3D &p2)
 Gets the distance between two points in a 3D space.
 
double BASE_IMPEXP mrpt::math::distance (const TLine2D &r1, const TLine2D &r2)
 Gets the distance between two lines in a 2D space.
 
double BASE_IMPEXP mrpt::math::distance (const TLine3D &r1, const TLine3D &r2)
 Gets the distance between two lines in a 3D space.
 
double BASE_IMPEXP mrpt::math::distance (const TPlane &p1, const TPlane &p2)
 Gets the distance between two planes.
 
double BASE_IMPEXP mrpt::math::distance (const TPolygon2D &p1, const TPolygon2D &p2)
 Gets the distance between two polygons in a 2D space.
 
double BASE_IMPEXP mrpt::math::distance (const TPolygon2D &p1, const TSegment2D &s2)
 Gets the distance between a polygon and a segment in a 2D space.
 
double mrpt::math::distance (const TSegment2D &s1, const TPolygon2D &p2)
 Gets the distance between a segment and a polygon in a 2D space.
 
double BASE_IMPEXP mrpt::math::distance (const TPolygon2D &p1, const TLine2D &l2)
 Gets the distance between a polygon and a line in a 2D space.
 
double mrpt::math::distance (const TLine2D &l1, const TPolygon2D &p2)
 
double BASE_IMPEXP mrpt::math::distance (const TPolygon3D &p1, const TPolygon3D &p2)
 Gets the distance between two polygons in a 3D space.
 
double BASE_IMPEXP mrpt::math::distance (const TPolygon3D &p1, const TSegment3D &s2)
 Gets the distance between a polygon and a segment in a 3D space.
 
double mrpt::math::distance (const TSegment3D &s1, const TPolygon3D &p2)
 Gets the distance between a segment and a polygon in a 3D space.
 
double BASE_IMPEXP mrpt::math::distance (const TPolygon3D &p1, const TLine3D &l2)
 Gets the distance between a polygon and a line in a 3D space.
 
double mrpt::math::distance (const TLine3D &l1, const TPolygon3D &p2)
 Gets the distance between a line and a polygon in a 3D space.
 
double BASE_IMPEXP mrpt::math::distance (const TPolygon3D &po, const TPlane &pl)
 Gets the distance between a polygon and a plane.
 
double mrpt::math::distance (const TPlane &pl, const TPolygon3D &po)
 Gets the distance between a plane and a polygon.
 

Bound checkers

void BASE_IMPEXP mrpt::math::getRectangleBounds (const std::vector< TPoint2D > &poly, TPoint2D &pMin, TPoint2D &pMax)
 Gets the rectangular bounds of a 2D polygon or set of 2D points.
 
void BASE_IMPEXP mrpt::math::getPrismBounds (const std::vector< TPoint3D > &poly, TPoint3D &pMin, TPoint3D &pMax)
 Gets the prism bounds of a 3D polygon or set of 3D points.
 

Creation of planes from poses

void BASE_IMPEXP mrpt::math::createPlaneFromPoseXY (const CPose3D &pose, TPlane &plane)
 Given a pose, creates a plane orthogonal to its Z vector.
 
void BASE_IMPEXP mrpt::math::createPlaneFromPoseXZ (const CPose3D &pose, TPlane &plane)
 Given a pose, creates a plane orthogonal to its Y vector.
 
void BASE_IMPEXP mrpt::math::createPlaneFromPoseYZ (const CPose3D &pose, TPlane &plane)
 Given a pose, creates a plane orthogonal to its X vector.
 
void BASE_IMPEXP mrpt::math::createPlaneFromPoseAndNormal (const CPose3D &pose, const double(&normal)[3], TPlane &plane)
 Given a pose and any vector, creates a plane orthogonal to that vector in the pose's coordinates.
 
void BASE_IMPEXP mrpt::math::generateAxisBaseFromDirectionAndAxis (const double(&vec)[3], char coord, CMatrixDouble &matrix)
 Creates a rotation matrix so that the coordinate given (0 for x, 1 for y, 2 for z) corresponds to the vector.
 

Linear regression methods

double BASE_IMPEXP mrpt::math::getRegressionLine (const std::vector< TPoint2D > &points, TLine2D &line)
 Using eigenvalues, gets the best fitting line for a set of 2D points.
 
double BASE_IMPEXP mrpt::math::getRegressionLine (const std::vector< TPoint3D > &points, TLine3D &line)
 Using eigenvalues, gets the best fitting line for a set of 3D points.
 
double BASE_IMPEXP mrpt::math::getRegressionPlane (const std::vector< TPoint3D > &points, TPlane &plane)
 Using eigenvalues, gets the best fitting plane for a set of 3D points.
 

Miscellaneous Geometry methods

void BASE_IMPEXP mrpt::math::assemblePolygons (const std::vector< TSegment3D > &segms, std::vector< TPolygon3D > &polys)
 Tries to assemble a set of segments into a set of closed polygons.
 
void BASE_IMPEXP mrpt::math::assemblePolygons (const std::vector< TSegment3D > &segms, std::vector< TPolygon3D > &polys, std::vector< TSegment3D > &remainder)
 Tries to assemble a set of segments into a set of closed polygons, returning the unused segments as another out parameter.
 
void BASE_IMPEXP mrpt::math::assemblePolygons (const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys)
 Extracts all the polygons, including those formed from segments, from the set of objects.
 
void BASE_IMPEXP mrpt::math::assemblePolygons (const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys, std::vector< TObject3D > &remainder)
 Extracts all the polygons, including those formed from segments, from the set of objects.
 
void BASE_IMPEXP mrpt::math::assemblePolygons (const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys, std::vector< TSegment3D > &remainder1, std::vector< TObject3D > &remainder2)
 Extracts all the polygons, including those formed from segments, from the set of objects.
 
void mrpt::math::setEpsilon (double nE)
 Changes the value of the geometric epsilon.
 
double mrpt::math::getEpsilon ()
 Gets the value of the geometric epsilon.
 
bool BASE_IMPEXP mrpt::math::splitInConvexComponents (const TPolygon2D &poly, vector< TPolygon2D > &components)
 Splits a 2D polygon into convex components.
 
bool BASE_IMPEXP mrpt::math::splitInConvexComponents (const TPolygon3D &poly, vector< TPolygon3D > &components)
 Splits a 3D polygon into convex components.
 
void BASE_IMPEXP mrpt::math::getSegmentBisector (const TSegment2D &sgm, TLine2D &bis)
 Gets the bisector of a 2D segment.
 
void BASE_IMPEXP mrpt::math::getSegmentBisector (const TSegment3D &sgm, TPlane &bis)
 Gets the bisector of a 3D segment.
 
void BASE_IMPEXP mrpt::math::getAngleBisector (const TLine2D &l1, const TLine2D &l2, TLine2D &bis)
 Gets the bisector of two lines or segments (implicit constructor will be used if necessary)
 
void BASE_IMPEXP mrpt::math::getAngleBisector (const TLine3D &l1, const TLine3D &l2, TLine3D &bis)
 Gets the bisector of two lines or segments (implicit constructor will be used if necessary)
 
bool BASE_IMPEXP mrpt::math::traceRay (const vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
 Fast ray tracing method using polygons' properties.
 
bool mrpt::math::traceRay (const vector< TPolygon3D > &vec, const mrpt::poses::CPose3D &pose, double &dist)
 Fast ray tracing method using polygons' properties.
 
template<class T , class U , class V >
void mrpt::math::crossProduct3D (const T &v0, const U &v1, V &vOut)
 Computes the cross product of two 3D vectors, returning a vector normal to both.
 
template<class T >
void mrpt::math::crossProduct3D (const std::vector< T > &v0, const std::vector< T > &v1, std::vector< T > &v_out)
 
template<class VEC1 , class VEC2 >
Eigen::Matrix< double, 3, 1 > mrpt::math::crossProduct3D (const VEC1 &v0, const VEC2 &v1)
 
template<class VECTOR , class MATRIX >
void mrpt::math::skew_symmetric3 (const VECTOR &v, MATRIX &M)
 Computes the 3x3 skew symmetric matrix from a 3-vector or 3-array:

\[ M([x ~ y ~ z]^\top) = \left( \begin{array}{c c c} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{array} \right) \]

.

 
template<class VECTOR >
mrpt::math::CMatrixDouble33 mrpt::math::skew_symmetric3 (const VECTOR &v)
 
template<class VECTOR , class MATRIX >
void mrpt::math::skew_symmetric3_neg (const VECTOR &v, MATRIX &M)
 Computes the negative version of a 3x3 skew symmetric matrix from a 3-vector or 3-array:

\[ -M([x ~ y ~ z]^\top) = \left( \begin{array}{c c c} 0 & z & -y \\ -z & 0 & x \\ y & -x & 0 \end{array} \right) \]

.

 
template<class VECTOR >
mrpt::math::CMatrixDouble33 mrpt::math::skew_symmetric3_neg (const VECTOR &v)
 
template<class T , class U >
bool mrpt::math::vectorsAreParallel2D (const T &v1, const U &v2)
 Returns true if two 2D vectors are parallel.
 
template<class T , class U >
bool mrpt::math::vectorsAreParallel3D (const T &v1, const U &v2)
 Returns true if two 3D vectors are parallel.
 
double BASE_IMPEXP mrpt::math::minimumDistanceFromPointToSegment (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2, double &out_x, double &out_y)
 Computes the closest point from a given point to a segment, and returns that minimum distance.
 
double BASE_IMPEXP mrpt::math::minimumDistanceFromPointToSegment (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2, float &out_x, float &out_y)
 Computes the closest point from a given point to a segment, and returns that minimum distance.
 
void BASE_IMPEXP mrpt::math::closestFromPointToSegment (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2, double &out_x, double &out_y)
 Computes the closest point from a given point to a segment.
 
void BASE_IMPEXP mrpt::math::closestFromPointToLine (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2, double &out_x, double &out_y)
 Computes the closest point from a given point to a (infinite) line.
 
double BASE_IMPEXP mrpt::math::closestSquareDistanceFromPointToLine (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2)
 Returns the square distance from a point to a line.
 
template<typename T >
mrpt::math::distanceBetweenPoints (const T x1, const T y1, const T x2, const T y2)
 Returns the distance between 2 points in 2D.
 
template<typename T >
mrpt::math::distanceBetweenPoints (const T x1, const T y1, const T z1, const T x2, const T y2, const T z2)
 Returns the distance between 2 points in 3D.
 
template<typename T >
mrpt::math::distanceSqrBetweenPoints (const T x1, const T y1, const T x2, const T y2)
 Returns the square distance between 2 points in 2D.
 
template<typename T >
mrpt::math::distanceSqrBetweenPoints (const T x1, const T y1, const T z1, const T x2, const T y2, const T z2)
 Returns the square distance between 2 points in 3D.
 
bool BASE_IMPEXP mrpt::math::SegmentsIntersection (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4, double &ix, double &iy)
 Returns the intersection point, and if it exists, between two segments.
 
bool BASE_IMPEXP mrpt::math::SegmentsIntersection (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4, float &ix, float &iy)
 Returns the intersection point, and if it exists, between two segments.
 
bool BASE_IMPEXP mrpt::math::pointIntoPolygon2D (const double &px, const double &py, unsigned int polyEdges, const double *poly_xs, const double *poly_ys)
 Returns true if the 2D point (px,py) falls INTO the given polygon.
 
template<typename T >
bool mrpt::math::pointIntoQuadrangle (T x, T y, T v1x, T v1y, T v2x, T v2y, T v3x, T v3y, T v4x, T v4y)
 Specialized method to check whether a point (x,y) falls into a quadrangle.
 
double BASE_IMPEXP mrpt::math::distancePointToPolygon2D (const double &px, const double &py, unsigned int polyEdges, const double *poly_xs, const double *poly_ys)
 Returns the closest distance of a given 2D point to a polygon, or "0" if the point is INTO the polygon or its perimeter.
 
bool BASE_IMPEXP mrpt::math::minDistBetweenLines (const double &p1_x, const double &p1_y, const double &p1_z, const double &p2_x, const double &p2_y, const double &p2_z, const double &p3_x, const double &p3_y, const double &p3_z, const double &p4_x, const double &p4_y, const double &p4_z, double &x, double &y, double &z, double &dist)
 Calculates the minimum distance between a pair of lines.
 
bool BASE_IMPEXP mrpt::math::RectanglesIntersection (const double &R1_x_min, const double &R1_x_max, const double &R1_y_min, const double &R1_y_max, const double &R2_x_min, const double &R2_x_max, const double &R2_y_min, const double &R2_y_max, const double &R2_pose_x, const double &R2_pose_y, const double &R2_pose_phi)
 Returns wether two rotated rectangles intersect.
 
template<class T >
CMatrixTemplateNumeric< T > mrpt::math::generateAxisBaseFromDirection (T dx, T dy, T dz)
 Computes an axis base (a set of three 3D normal vectors) with the given vector being the first of them.
 
template<typename VECTOR_LIKE , typename Precision , typename MATRIX_LIKE >
void mrpt::math::rodrigues_so3_exp (const VECTOR_LIKE &w, const Precision A, const Precision B, MATRIX_LIKE &R)
 Compute a rotation exponential using the Rodrigues Formula.
 

SLERP (Spherical Linear Interpolation) functions

template<typename T >
void mrpt::math::slerp (const CQuaternion< T > &q0, const CQuaternion< T > &q1, const double t, CQuaternion< T > &q)
 SLERP interpolation between two quaternions.
 
void BASE_IMPEXP mrpt::math::slerp (const CPose3D &q0, const CPose3D &q1, const double t, CPose3D &p)
 SLERP interpolation between two 6D poses - like mrpt::math::slerp for quaternions, but interpolates the [X,Y,Z] coordinates as well.
 
void BASE_IMPEXP mrpt::math::slerp (const CPose3DQuat &q0, const CPose3DQuat &q1, const double t, CPose3DQuat &p)
 

Typedef Documentation

typedef TPlane mrpt::math::TPlane3D

Definition at line 1068 of file lightweight_geom_data.h.

Function Documentation

bool BASE_IMPEXP mrpt::math::areAligned ( const std::vector< TPoint2D > &  points)

Checks whether this set of points acceptably fits a 2D line.

See Also
geometryEpsilon
bool BASE_IMPEXP mrpt::math::areAligned ( const std::vector< TPoint2D > &  points,
TLine2D &  r 
)

Checks whether this set of points acceptably fits a 2D line, and if it's the case returns it in the second argument.

See Also
geometryEpsilon
bool BASE_IMPEXP mrpt::math::areAligned ( const std::vector< TPoint3D > &  points)

Checks whether this set of points acceptably fits a 3D line.

See Also
geometryEpsilon
bool BASE_IMPEXP mrpt::math::areAligned ( const std::vector< TPoint3D > &  points,
TLine3D &  r 
)

Checks whether this set of points acceptably fits a 3D line, and if it's the case returns it in the second argument.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TSegment3D > &  segms,
std::vector< TPolygon3D > &  polys 
)

Tries to assemble a set of segments into a set of closed polygons.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TSegment3D > &  segms,
std::vector< TPolygon3D > &  polys,
std::vector< TSegment3D > &  remainder 
)

Tries to assemble a set of segments into a set of closed polygons, returning the unused segments as another out parameter.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TObject3D > &  objs,
std::vector< TPolygon3D > &  polys 
)

Extracts all the polygons, including those formed from segments, from the set of objects.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TObject3D > &  objs,
std::vector< TPolygon3D > &  polys,
std::vector< TObject3D > &  remainder 
)

Extracts all the polygons, including those formed from segments, from the set of objects.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TObject3D > &  objs,
std::vector< TPolygon3D > &  polys,
std::vector< TSegment3D > &  remainder1,
std::vector< TObject3D > &  remainder2 
)

Extracts all the polygons, including those formed from segments, from the set of objects.

void BASE_IMPEXP mrpt::math::closestFromPointToLine ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
double &  out_x,
double &  out_y 
)

Computes the closest point from a given point to a (infinite) line.

See Also
closestFromPointToSegment
void BASE_IMPEXP mrpt::math::closestFromPointToSegment ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
double &  out_x,
double &  out_y 
)

Computes the closest point from a given point to a segment.

See Also
closestFromPointToLine
double BASE_IMPEXP mrpt::math::closestSquareDistanceFromPointToLine ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2 
)

Returns the square distance from a point to a line.

bool BASE_IMPEXP mrpt::math::conformAPlane ( const std::vector< TPoint3D > &  points)

Checks whether this polygon or set of points acceptably fits a plane.

See Also
TPolygon3D,geometryEpsilon
bool BASE_IMPEXP mrpt::math::conformAPlane ( const std::vector< TPoint3D > &  points,
TPlane &  p 
)

Checks whether this polygon or set of points acceptably fits a plane, and if it's the case returns it in the second argument.

See Also
TPolygon3D,geometryEpsilon
void BASE_IMPEXP mrpt::math::createFromPoseAndVector ( const CPose3D p,
const double(&)  vector[3],
TLine3D &  r 
)

Gets a 3D line corresponding to any arbitrary vector, in the base given by the pose.

An implicit constructor is used if a TPose3D is given.

See Also
createFromPoseX,createFromPoseY,createFromPoseZ
void BASE_IMPEXP mrpt::math::createFromPoseAndVector ( const TPose2D &  p,
const double(&)  vector[2],
TLine2D &  r 
)

Gets a 2D line corresponding to any arbitrary vector, in the base given the given pose.

An implicit constructor is used if a CPose2D is given.

See Also
createFromPoseY,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseX ( const CPose3D p,
TLine3D &  r 
)

Gets a 3D line corresponding to the X axis in a given pose.

An implicit constructor is used if a TPose3D is given.

See Also
createFromPoseY,createFromPoseZ,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseX ( const TPose2D &  p,
TLine2D &  r 
)

Gets a 2D line corresponding to the X axis in a given pose.

An implicit constructor is used if a CPose2D is given.

See Also
createFromPoseY,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseY ( const CPose3D p,
TLine3D &  r 
)

Gets a 3D line corresponding to the Y axis in a given pose.

An implicit constructor is used if a TPose3D is given.

See Also
createFromPoseX,createFromPoseZ,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseY ( const TPose2D &  p,
TLine2D &  r 
)

Gets a 2D line corresponding to the Y axis in a given pose.

An implicit constructor is used if a CPose2D is given.

See Also
createFromPoseX,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseZ ( const CPose3D p,
TLine3D &  r 
)

Gets a 3D line corresponding to the Z axis in a given pose.

An implicit constructor is used if a TPose3D is given.

See Also
createFromPoseX,createFromPoseY,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createPlaneFromPoseAndNormal ( const CPose3D pose,
const double(&)  normal[3],
TPlane &  plane 
)

Given a pose and any vector, creates a plane orthogonal to that vector in the pose's coordinates.

See Also
createPlaneFromPoseXY,createPlaneFromPoseXZ,createPlaneFromPoseYZ
void BASE_IMPEXP mrpt::math::createPlaneFromPoseXY ( const CPose3D pose,
TPlane &  plane 
)

Given a pose, creates a plane orthogonal to its Z vector.

See Also
createPlaneFromPoseXZ,createPlaneFromPoseYZ,createPlaneFromPoseAndNormal
void BASE_IMPEXP mrpt::math::createPlaneFromPoseXZ ( const CPose3D pose,
TPlane &  plane 
)

Given a pose, creates a plane orthogonal to its Y vector.

See Also
createPlaneFromPoseXY,createPlaneFromPoseYZ,createPlaneFromPoseAndNormal
void BASE_IMPEXP mrpt::math::createPlaneFromPoseYZ ( const CPose3D pose,
TPlane &  plane 
)

Given a pose, creates a plane orthogonal to its X vector.

See Also
createPlaneFromPoseXY,createPlaneFromPoseXZ,createPlaneFromPoseAndNormal
template<class T , class U , class V >
void mrpt::math::crossProduct3D ( const T &  v0,
const U &  v1,
V &  vOut 
)
inline

Computes the cross product of two 3D vectors, returning a vector normal to both.

It uses the simple implementation:

\[ v_out = \left( \begin{array}{c c c} \hat{i} ~ \hat{j} ~ \hat{k} \\ x0 ~ y0 ~ z0 \\ x1 ~ y1 ~ z1 \\ \end{array} \right) \]

Definition at line 764 of file geometry.h.

Referenced by mrpt::math::generateAxisBaseFromDirection().

template<class T >
void mrpt::math::crossProduct3D ( const std::vector< T > &  v0,
const std::vector< T > &  v1,
std::vector< T > &  v_out 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 772 of file geometry.h.

template<class VEC1 , class VEC2 >
Eigen::Matrix<double,3,1> mrpt::math::crossProduct3D ( const VEC1 &  v0,
const VEC2 &  v1 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 787 of file geometry.h.

References ASSERT_.

double BASE_IMPEXP mrpt::math::distance ( const TPoint2D &  p1,
const TPoint2D &  p2 
)
double BASE_IMPEXP mrpt::math::distance ( const TPoint3D &  p1,
const TPoint3D &  p2 
)

Gets the distance between two points in a 3D space.

double BASE_IMPEXP mrpt::math::distance ( const TLine2D &  r1,
const TLine2D &  r2 
)

Gets the distance between two lines in a 2D space.

double BASE_IMPEXP mrpt::math::distance ( const TLine3D &  r1,
const TLine3D &  r2 
)

Gets the distance between two lines in a 3D space.

double BASE_IMPEXP mrpt::math::distance ( const TPlane &  p1,
const TPlane &  p2 
)

Gets the distance between two planes.

It will be zero if the planes are not parallel.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon2D &  p1,
const TPolygon2D &  p2 
)

Gets the distance between two polygons in a 2D space.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon2D &  p1,
const TSegment2D &  s2 
)

Gets the distance between a polygon and a segment in a 2D space.

double mrpt::math::distance ( const TSegment2D &  s1,
const TPolygon2D &  p2 
)
inline

Gets the distance between a segment and a polygon in a 2D space.

Definition at line 562 of file geometry.h.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon2D &  p1,
const TLine2D &  l2 
)

Gets the distance between a polygon and a line in a 2D space.

double mrpt::math::distance ( const TLine2D &  l1,
const TPolygon2D &  p2 
)
inline

Definition at line 569 of file geometry.h.

References mrpt::math::distance().

double BASE_IMPEXP mrpt::math::distance ( const TPolygon3D &  p1,
const TPolygon3D &  p2 
)

Gets the distance between two polygons in a 3D space.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon3D &  p1,
const TSegment3D &  s2 
)

Gets the distance between a polygon and a segment in a 3D space.

double mrpt::math::distance ( const TSegment3D &  s1,
const TPolygon3D &  p2 
)
inline

Gets the distance between a segment and a polygon in a 3D space.

Definition at line 583 of file geometry.h.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon3D &  p1,
const TLine3D &  l2 
)

Gets the distance between a polygon and a line in a 3D space.

double mrpt::math::distance ( const TLine3D &  l1,
const TPolygon3D &  p2 
)
inline

Gets the distance between a line and a polygon in a 3D space.

Definition at line 593 of file geometry.h.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon3D &  po,
const TPlane &  pl 
)

Gets the distance between a polygon and a plane.

double mrpt::math::distance ( const TPlane &  pl,
const TPolygon3D &  po 
)
inline

Gets the distance between a plane and a polygon.

Definition at line 603 of file geometry.h.

template<typename T >
T mrpt::math::distanceBetweenPoints ( const T  x1,
const T  y1,
const T  x2,
const T  y2 
)

Returns the distance between 2 points in 2D.

Definition at line 927 of file geometry.h.

template<typename T >
T mrpt::math::distanceBetweenPoints ( const T  x1,
const T  y1,
const T  z1,
const T  x2,
const T  y2,
const T  z2 
)

Returns the distance between 2 points in 3D.

Definition at line 933 of file geometry.h.

double BASE_IMPEXP mrpt::math::distancePointToPolygon2D ( const double &  px,
const double &  py,
unsigned int  polyEdges,
const double *  poly_xs,
const double *  poly_ys 
)

Returns the closest distance of a given 2D point to a polygon, or "0" if the point is INTO the polygon or its perimeter.

template<typename T >
T mrpt::math::distanceSqrBetweenPoints ( const T  x1,
const T  y1,
const T  x2,
const T  y2 
)

Returns the square distance between 2 points in 2D.

Definition at line 939 of file geometry.h.

template<typename T >
T mrpt::math::distanceSqrBetweenPoints ( const T  x1,
const T  y1,
const T  z1,
const T  x2,
const T  y2,
const T  z2 
)

Returns the square distance between 2 points in 3D.

Definition at line 945 of file geometry.h.

template<class T >
CMatrixTemplateNumeric<T> mrpt::math::generateAxisBaseFromDirection ( dx,
dy,
dz 
)

Computes an axis base (a set of three 3D normal vectors) with the given vector being the first of them.

NOTE: Make sure of passing all floats or doubles and that the template of the receiving matrix is of the same type!

If $ d = [ dx ~ dy ~ dz ] $ is the input vector, then this function returns a matrix $ M $ such as:

\[ M = \left( \begin{array}{c c c} v^1_x ~ v^2_x ~ v^3_x \\ v^1_y ~ v^2_y ~ v^3_y \\ v^1_z ~ v^2_z ~ v^3_z \end{array} \right) \]

And the three normal vectors are computed as:

\[ v^1 = \frac{d}{|d|} \]

 If (dx!=0 or dy!=0):

\[ v^2 = \frac{[-dy ~ dx ~ 0 ]}{\sqrt{dx^2+dy^2}} \]

otherwise (the direction vector is vertical):

\[ v^2 = [1 ~ 0 ~ 0] \]

 And finally, the third vector is the cross product of the others:

\[ v^3 = v^1 \times v^2 \]

Returns
The 3x3 matrix (CMatrixTemplateNumeric<T>), containing one vector per column. Throws an std::exception on invalid input (i.e. null direction vector)

(JLB @ 18-SEP-2007)

Definition at line 1069 of file geometry.h.

References mrpt::math::crossProduct3D(), MRPT_END, MRPT_START, mrpt::utils::square(), and THROW_EXCEPTION.

void BASE_IMPEXP mrpt::math::generateAxisBaseFromDirectionAndAxis ( const double(&)  vec[3],
char  coord,
CMatrixDouble &  matrix 
)

Creates a rotation matrix so that the coordinate given (0 for x, 1 for y, 2 for z) corresponds to the vector.

double BASE_IMPEXP mrpt::math::getAngle ( const TPlane &  p1,
const TPlane &  p2 
)

Computes the angle between two planes.

Referenced by mrpt::math::getAngle().

double BASE_IMPEXP mrpt::math::getAngle ( const TPlane &  p1,
const TLine3D &  r2 
)

Computes the angle between a plane and a 3D line or segment (implicit constructor will be used if passing a segment instead of a line).

double mrpt::math::getAngle ( const TLine3D &  r1,
const TPlane &  p2 
)
inline

Computes the angle between a 3D line or segment and a plane (implicit constructor will be used if passing a segment instead of a line).

Definition at line 198 of file geometry.h.

References mrpt::math::getAngle().

double BASE_IMPEXP mrpt::math::getAngle ( const TLine3D &  r1,
const TLine3D &  r2 
)

Computes the angle between two 3D lines or segments (implicit constructor will be used if passing a segment instead of a line).

double BASE_IMPEXP mrpt::math::getAngle ( const TLine2D &  r1,
const TLine2D &  r2 
)

Computes the angle between two 2D lines or segments (implicit constructor will be used if passing a segment instead of a line).

void BASE_IMPEXP mrpt::math::getAngleBisector ( const TLine2D &  l1,
const TLine2D &  l2,
TLine2D &  bis 
)

Gets the bisector of two lines or segments (implicit constructor will be used if necessary)

void BASE_IMPEXP mrpt::math::getAngleBisector ( const TLine3D &  l1,
const TLine3D &  l2,
TLine3D &  bis 
)

Gets the bisector of two lines or segments (implicit constructor will be used if necessary)

Exceptions
std::logic_errorif the lines do not fit in a single plane.
double mrpt::math::getEpsilon ( )
inline

Gets the value of the geometric epsilon.

See Also
geometryEpsilon,setEpsilon

Definition at line 705 of file geometry.h.

References mrpt::math::geometryEpsilon.

void BASE_IMPEXP mrpt::math::getPrismBounds ( const std::vector< TPoint3D > &  poly,
TPoint3D &  pMin,
TPoint3D &  pMax 
)

Gets the prism bounds of a 3D polygon or set of 3D points.

void BASE_IMPEXP mrpt::math::getRectangleBounds ( const std::vector< TPoint2D > &  poly,
TPoint2D &  pMin,
TPoint2D &  pMax 
)

Gets the rectangular bounds of a 2D polygon or set of 2D points.

double BASE_IMPEXP mrpt::math::getRegressionLine ( const std::vector< TPoint2D > &  points,
TLine2D &  line 
)

Using eigenvalues, gets the best fitting line for a set of 2D points.

Returns an estimation of the error.

See Also
spline, leastSquareLinearFit
double BASE_IMPEXP mrpt::math::getRegressionLine ( const std::vector< TPoint3D > &  points,
TLine3D &  line 
)

Using eigenvalues, gets the best fitting line for a set of 3D points.

Returns an estimation of the error.

See Also
spline, leastSquareLinearFit
double BASE_IMPEXP mrpt::math::getRegressionPlane ( const std::vector< TPoint3D > &  points,
TPlane &  plane 
)

Using eigenvalues, gets the best fitting plane for a set of 3D points.

Returns an estimation of the error.

See Also
spline, leastSquareLinearFit
void BASE_IMPEXP mrpt::math::getSegmentBisector ( const TSegment2D &  sgm,
TLine2D &  bis 
)

Gets the bisector of a 2D segment.

void BASE_IMPEXP mrpt::math::getSegmentBisector ( const TSegment3D &  sgm,
TPlane &  bis 
)

Gets the bisector of a 3D segment.

bool BASE_IMPEXP mrpt::math::intersect ( const TSegment3D &  s1,
const TSegment3D &  s2,
TObject3D &  obj 
)

Gets the intersection between two 3D segments.

See Also
TObject3D

Referenced by mrpt::math::intersect().

bool BASE_IMPEXP mrpt::math::intersect ( const TSegment3D &  s1,
const TPlane &  p2,
TObject3D &  obj 
)

Gets the intersection between a 3D segment and a plane.

See Also
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TSegment3D &  s1,
const TLine3D &  r2,
TObject3D &  obj 
)

Gets the intersection between a 3D segment and a 3D line.

See Also
TObject3D
bool mrpt::math::intersect ( const TPlane &  p1,
const TSegment3D &  s2,
TObject3D &  obj 
)
inline

Gets the intersection between a plane and a 3D segment.

See Also
TObject3D

Definition at line 128 of file geometry.h.

References mrpt::math::intersect().

bool BASE_IMPEXP mrpt::math::intersect ( const TPlane &  p1,
const TPlane &  p2,
TObject3D &  obj 
)

Gets the intersection between two planes.

See Also
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TPlane &  p1,
const TLine3D &  p2,
TObject3D &  obj 
)

Gets the intersection between a plane and a 3D line.

See Also
TObject3D
bool mrpt::math::intersect ( const TLine3D &  r1,
const TSegment3D &  s2,
TObject3D &  obj 
)
inline

Gets the intersection between a 3D line and a 3D segment.

See Also
TObject3D

Definition at line 145 of file geometry.h.

References mrpt::math::intersect().

bool mrpt::math::intersect ( const TLine3D &  r1,
const TPlane &  p2,
TObject3D &  obj 
)
inline

Gets the intersection between a 3D line and a plane.

See Also
TObject3D

Definition at line 152 of file geometry.h.

References mrpt::math::intersect().

bool BASE_IMPEXP mrpt::math::intersect ( const TLine3D &  r1,
const TLine3D &  r2,
TObject3D &  obj 
)

Gets the intersection between two 3D lines.

See Also
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TLine2D &  r1,
const TLine2D &  r2,
TObject2D &  obj 
)

Gets the intersection between two 2D lines.

See Also
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TLine2D &  r1,
const TSegment2D &  s2,
TObject2D &  obj 
)

Gets the intersection between a 2D line and a 2D segment.

See Also
TObject2D
bool mrpt::math::intersect ( const TSegment2D &  s1,
const TLine2D &  r2,
TObject2D &  obj 
)
inline

Gets the intersection between a 2D line and a 2D segment.

See Also
TObject2D

Definition at line 174 of file geometry.h.

References mrpt::math::intersect().

bool BASE_IMPEXP mrpt::math::intersect ( const TSegment2D &  s1,
const TSegment2D &  s2,
TObject2D &  obj 
)

Gets the intersection between two 2D segments.

See Also
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon2D &  p1,
const TSegment2D &  s2,
TObject2D &  obj 
)

Gets the intersection between a 2D polygon and a 2D segment.

See Also
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon2D &  p1,
const TLine2D &  r2,
TObject2D &  obj 
)

Gets the intersection between a 2D polygon and a 2D line.

See Also
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon2D &  p1,
const TPolygon2D &  p2,
TObject2D &  obj 
)

Gets the intersection between two 2D polygons.

See Also
TObject2D
bool mrpt::math::intersect ( const TSegment2D &  s1,
const TPolygon2D &  p2,
TObject2D &  obj 
)
inline

Gets the intersection between a 2D segment and a 2D polygon.

See Also
TObject2D

Definition at line 423 of file geometry.h.

bool mrpt::math::intersect ( const TLine2D &  r1,
const TPolygon2D &  p2,
TObject2D &  obj 
)
inline

Gets the intersection between a 2D line and a 2D polygon.

See Also
TObject2D

Definition at line 430 of file geometry.h.

bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon3D &  p1,
const TSegment3D &  s2,
TObject3D &  obj 
)

Gets the intersection between a 3D polygon and a 3D segment.

See Also
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon3D &  p1,
const TLine3D &  r2,
TObject3D &  obj 
)

Gets the intersection between a 3D polygon and a 3D line.

See Also
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon3D &  p1,
const TPlane &  p2,
TObject3D &  obj 
)

Gets the intersection between a 3D polygon and a plane.

See Also
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon3D &  p1,
const TPolygon3D &  p2,
TObject3D &  obj 
)

Gets the intersection between two 3D polygons.

See Also
TObject3D
bool mrpt::math::intersect ( const TSegment3D &  s1,
const TPolygon3D &  p2,
TObject3D &  obj 
)
inline

Gets the intersection between a 3D segment and a 3D polygon.

See Also
TObject3D

Definition at line 457 of file geometry.h.

bool mrpt::math::intersect ( const TLine3D &  r1,
const TPolygon3D &  p2,
TObject3D &  obj 
)
inline

Gets the intersection between a 3D line and a 3D polygon.

See Also
TObject3D

Definition at line 464 of file geometry.h.

bool mrpt::math::intersect ( const TPlane &  p1,
const TPolygon3D &  p2,
TObject3D &  obj 
)
inline

Gets the intersection between a plane and a 3D polygon.

See Also
TObject3D

Definition at line 471 of file geometry.h.

size_t BASE_IMPEXP mrpt::math::intersect ( const std::vector< TPolygon3D > &  v1,
const std::vector< TPolygon3D > &  v2,
CSparseMatrixTemplate< TObject3D > &  objs 
)

Gets the intersection between two sets of 3D polygons.

The intersection is returned as an sparse matrix with each pair of polygons' intersections, and the return value is the amount of intersections found.

See Also
TObject3D,CSparseMatrixTemplate
size_t BASE_IMPEXP mrpt::math::intersect ( const std::vector< TPolygon3D > &  v1,
const std::vector< TPolygon3D > &  v2,
std::vector< TObject3D > &  objs 
)

Gets the intersection between two sets of 3D polygons.

The intersection is returned as a vector with every intersection found, and the return value is the amount of intersections found.

See Also
TObject3D
template<class T , class U , class O >
size_t mrpt::math::intersect ( const std::vector< T > &  v1,
const std::vector< U > &  v2,
CSparseMatrixTemplate< O > &  objs 
)

Gets the intersection between vectors of geometric objects and returns it in a sparse matrix of either TObject2D or TObject3D.

See Also
TObject2D,TObject3D,CSparseMatrix

Definition at line 494 of file geometry.h.

References mrpt::math::CSparseMatrixTemplate< T >::clear(), mrpt::math::CSparseMatrixTemplate< T >::getNonNullElements(), mrpt::math::intersect(), and mrpt::math::CSparseMatrixTemplate< T >::resize().

template<class T , class U , class O >
size_t mrpt::math::intersect ( const std::vector< T > &  v1,
const std::vector< U > &  v2,
std::vector< O >  objs 
)

Gets the intersection between vectors of geometric objects and returns it in a vector of either TObject2D or TObject3D.

See Also
TObject2D,TObject3D

Definition at line 507 of file geometry.h.

bool BASE_IMPEXP mrpt::math::intersect ( const TObject2D &  o1,
const TObject2D &  o2,
TObject2D &  obj 
)

Gets the intersection between any pair of 2D objects.

bool BASE_IMPEXP mrpt::math::intersect ( const TObject3D &  o1,
const TObject3D &  o2,
TObject3D &  obj 
)

Gets the intersection between any pair of 3D objects.

bool BASE_IMPEXP mrpt::math::minDistBetweenLines ( const double &  p1_x,
const double &  p1_y,
const double &  p1_z,
const double &  p2_x,
const double &  p2_y,
const double &  p2_z,
const double &  p3_x,
const double &  p3_y,
const double &  p3_z,
const double &  p4_x,
const double &  p4_y,
const double &  p4_z,
double &  x,
double &  y,
double &  z,
double &  dist 
)

Calculates the minimum distance between a pair of lines.

The lines are given by:

  • Line 1 = P1 + f (P2-P1)
  • Line 2 = P3 + f (P4-P3) The Euclidean distance is returned in "dist", and the mid point between the lines in (x,y,z)
    Returns
    It returns false if there is no solution, i.e. lines are (almost, up to EPS) parallel.
double BASE_IMPEXP mrpt::math::minimumDistanceFromPointToSegment ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
double &  out_x,
double &  out_y 
)

Computes the closest point from a given point to a segment, and returns that minimum distance.

double BASE_IMPEXP mrpt::math::minimumDistanceFromPointToSegment ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
float &  out_x,
float &  out_y 
)

Computes the closest point from a given point to a segment, and returns that minimum distance.

bool mrpt::math::operator!= ( const TPoint2D &  p1,
const TPoint2D &  p2 
)
inline

Exact comparison between 2D points.

Definition at line 597 of file lightweight_geom_data.h.

References mrpt::math::TPoint2D::x, and mrpt::math::TPoint2D::y.

bool mrpt::math::operator!= ( const TPoint3D &  p1,
const TPoint3D &  p2 
)
inline

Exact comparison between 3D points.

Definition at line 609 of file lightweight_geom_data.h.

References mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.

bool mrpt::math::operator!= ( const TPose2D &  p1,
const TPose2D &  p2 
)
inline

Exact comparison between 2D poses, taking possible cycles into account.

Definition at line 621 of file lightweight_geom_data.h.

References mrpt::math::TPose2D::phi, mrpt::mrpt::math::wrapTo2Pi(), mrpt::math::TPose2D::x, and mrpt::math::TPose2D::y.

bool mrpt::math::operator!= ( const TPose3D &  p1,
const TPose3D &  p2 
)
inline

Exact comparison between 3D poses, taking possible cycles into account.

Definition at line 633 of file lightweight_geom_data.h.

References mrpt::math::TPose3D::pitch, mrpt::math::TPose3D::roll, mrpt::mrpt::math::wrapTo2Pi(), mrpt::math::TPose3D::x, mrpt::math::TPose3D::y, mrpt::math::TPose3D::yaw, and mrpt::math::TPose3D::z.

bool mrpt::math::operator!= ( const TSegment2D &  s1,
const TSegment2D &  s2 
)
inline
bool mrpt::math::operator!= ( const TSegment3D &  s1,
const TSegment3D &  s2 
)
inline
TPoint3D mrpt::math::operator- ( const TPoint3D &  p1)
inline

Unary minus operator for 3D points.

Definition at line 585 of file lightweight_geom_data.h.

References mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.

std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPoint2D &  p 
)
std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPoint3D &  p 
)
std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPose2D &  p 
)
std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPose3D &  p 
)
std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPose3DQuat &  p 
)
BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPoint2D o 
)

TPoint2D binary output.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPoint3D o 
)

TPoint3D binary output.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPose2D o 
)

TPose2D binary output.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPose3D o 
)

TPose3D binary output.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TSegment2D s 
)
inline

TSegment2D binary output.

Definition at line 2358 of file lightweight_geom_data.h.

References mrpt::math::TSegment2D::point1, and mrpt::math::TSegment2D::point2.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TLine2D l 
)
inline

TLine2D binary output.

Definition at line 2371 of file lightweight_geom_data.h.

References mrpt::math::TLine2D::coefs.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TObject2D o 
)

TObject2D binary input.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TSegment3D s 
)
inline

TSegment3D binary output.

Definition at line 2393 of file lightweight_geom_data.h.

References mrpt::math::TSegment3D::point1, and mrpt::math::TSegment3D::point2.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TLine3D l 
)
inline

TLine3D binary output.

Definition at line 2406 of file lightweight_geom_data.h.

References mrpt::math::TLine3D::director, and mrpt::math::TLine3D::pBase.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPlane p 
)
inline

TPlane binary output.

Definition at line 2419 of file lightweight_geom_data.h.

References mrpt::math::TPlane::coefs.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TObject3D o 
)

TObject3D binary output.

bool mrpt::math::operator== ( const TPoint2D &  p1,
const TPoint2D &  p2 
)
inline

Exact comparison between 2D points.

Definition at line 591 of file lightweight_geom_data.h.

References mrpt::math::TPoint2D::x, and mrpt::math::TPoint2D::y.

bool mrpt::math::operator== ( const TPoint3D &  p1,
const TPoint3D &  p2 
)
inline

Exact comparison between 3D points.

Definition at line 603 of file lightweight_geom_data.h.

References mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.

bool mrpt::math::operator== ( const TPose2D &  p1,
const TPose2D &  p2 
)
inline

Exact comparison between 2D poses, taking possible cycles into account.

Definition at line 615 of file lightweight_geom_data.h.

References mrpt::math::TPose2D::phi, mrpt::mrpt::math::wrapTo2Pi(), mrpt::math::TPose2D::x, and mrpt::math::TPose2D::y.

bool mrpt::math::operator== ( const TPose3D &  p1,
const TPose3D &  p2 
)
inline

Exact comparison between 3D poses, taking possible cycles into account.

Definition at line 627 of file lightweight_geom_data.h.

References mrpt::math::TPose3D::pitch, mrpt::math::TPose3D::roll, mrpt::mrpt::math::wrapTo2Pi(), mrpt::math::TPose3D::x, mrpt::math::TPose3D::y, mrpt::math::TPose3D::yaw, and mrpt::math::TPose3D::z.

bool mrpt::math::operator== ( const TSegment2D &  s1,
const TSegment2D &  s2 
)
inline
bool mrpt::math::operator== ( const TSegment3D &  s1,
const TSegment3D &  s2 
)
inline
BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPoint2D o 
)

TPoint2D binary input.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPoint3D o 
)

TPoint3D binary input.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPose2D o 
)

TPose2D binary input.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPose3D o 
)

TPose3D binary input.

mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TSegment2D s 
)
inline

TSegment2D binary input.

Definition at line 2352 of file lightweight_geom_data.h.

References mrpt::math::TSegment2D::point1, and mrpt::math::TSegment2D::point2.

mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TLine2D l 
)
inline

TLine2D binary input.

Definition at line 2365 of file lightweight_geom_data.h.

References mrpt::math::TLine2D::coefs.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TObject2D o 
)

TObject2D binary input.

mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TSegment3D s 
)
inline

TSegment3D binary input.

Definition at line 2387 of file lightweight_geom_data.h.

References mrpt::math::TSegment3D::point1, and mrpt::math::TSegment3D::point2.

mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TLine3D l 
)
inline

TLine3D binary input.

Definition at line 2400 of file lightweight_geom_data.h.

References mrpt::math::TLine3D::director, and mrpt::math::TLine3D::pBase.

mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPlane p 
)
inline

TPlane binary input.

Definition at line 2413 of file lightweight_geom_data.h.

References mrpt::math::TPlane::coefs.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TObject3D o 
)

TObject3D binary input.

bool BASE_IMPEXP mrpt::math::pointIntoPolygon2D ( const double &  px,
const double &  py,
unsigned int  polyEdges,
const double *  poly_xs,
const double *  poly_ys 
)

Returns true if the 2D point (px,py) falls INTO the given polygon.

See Also
pointIntoQuadrangle
template<typename T >
bool mrpt::math::pointIntoQuadrangle ( x,
y,
v1x,
v1y,
v2x,
v2y,
v3x,
v3y,
v4x,
v4y 
)

Specialized method to check whether a point (x,y) falls into a quadrangle.

See Also
pointIntoPolygon2D

Definition at line 976 of file geometry.h.

void mrpt::math::project2D ( const TPoint2D &  point,
const CPose2D newXpose,
TPoint2D &  newPoint 
)
inline

Uses the given pose 2D to project a point into a new base.

Definition at line 349 of file geometry.h.

Referenced by mrpt::math::project2D().

void mrpt::math::project2D ( const TSegment2D &  segment,
const CPose2D newXpose,
TSegment2D &  newSegment 
)
inline

Uses the given pose 2D to project a segment into a new base.

Definition at line 355 of file geometry.h.

void BASE_IMPEXP mrpt::math::project2D ( const TLine2D &  line,
const CPose2D newXpose,
TLine2D &  newLine 
)

Uses the given pose 2D to project a line into a new base.

void BASE_IMPEXP mrpt::math::project2D ( const TPolygon2D &  polygon,
const CPose2D newXpose,
TPolygon2D &  newPolygon 
)

Uses the given pose 2D to project a polygon into a new base.

void BASE_IMPEXP mrpt::math::project2D ( const TObject2D &  object,
const CPose2D newXpose,
TObject2D &  newObject 
)

Uses the given pose 2D to project any 2D object into a new base.

template<class T >
void mrpt::math::project2D ( const T &  obj,
const TLine2D &  newXLine,
T &  newObj 
)

Projects any 2D object into the line's base, using its inverse pose.

If the object is exactly inside the line, this projection will zero its Y coordinate.

Definition at line 376 of file geometry.h.

References mrpt::math::TLine2D::getAsPose2D(), and mrpt::math::project2D().

template<class T >
void mrpt::math::project2D ( const T &  obj,
const TLine2D &  newXLine,
const TPoint2D &  newOrigin,
T &  newObj 
)

Projects any 2D object into the line's base, using its inverse pose and forcing the position of the new coordinate origin.

If the object is exactly inside the line, this projection will zero its Y coordinate.

Definition at line 385 of file geometry.h.

References mrpt::math::TLine2D::getAsPose2DForcingOrigin(), and mrpt::math::project2D().

template<class T >
void mrpt::math::project2D ( const std::vector< T > &  objs,
const CPose2D newXpose,
std::vector< T > &  newObjs 
)

Projects a set of 2D objects into the line's base.

Definition at line 394 of file geometry.h.

References mrpt::math::project2D().

void mrpt::math::project3D ( const TPoint3D &  point,
const CPose3D newXYpose,
TPoint3D &  newPoint 
)
inline

Uses the given pose 3D to project a point into a new base.

Definition at line 291 of file geometry.h.

References mrpt::poses::CPose3D::composePoint(), mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.

Referenced by mrpt::math::project3D().

void mrpt::math::project3D ( const TSegment3D &  segment,
const CPose3D newXYpose,
TSegment3D &  newSegment 
)
inline

Uses the given pose 3D to project a segment into a new base.

Definition at line 297 of file geometry.h.

void BASE_IMPEXP mrpt::math::project3D ( const TLine3D &  line,
const CPose3D newXYpose,
TLine3D &  newLine 
)

Uses the given pose 3D to project a line into a new base.

void BASE_IMPEXP mrpt::math::project3D ( const TPlane &  plane,
const CPose3D newXYpose,
TPlane &  newPlane 
)

Uses the given pose 3D to project a plane into a new base.

void BASE_IMPEXP mrpt::math::project3D ( const TPolygon3D &  polygon,
const CPose3D newXYpose,
TPolygon3D &  newPolygon 
)

Uses the given pose 3D to project a polygon into a new base.

void BASE_IMPEXP mrpt::math::project3D ( const TObject3D &  object,
const CPose3D newXYPose,
TObject3D &  newObject 
)

Uses the given pose 3D to project any 3D object into a new base.

template<class T >
void mrpt::math::project3D ( const T &  obj,
const TPlane &  newXYPlane,
T &  newObj 
)

Projects any 3D object into the plane's base, using its inverse pose.

If the object is exactly inside the plane, this projection will zero its Z coordinates.

Definition at line 321 of file geometry.h.

References mrpt::math::TPlane::getAsPose3D(), and mrpt::math::project3D().

template<class T >
void mrpt::math::project3D ( const T &  obj,
const TPlane &  newXYPlane,
const TPoint3D &  newOrigin,
T &  newObj 
)

Projects any 3D object into the plane's base, using its inverse pose and forcing the position of the new coordinates origin.

If the object is exactly inside the plane, this projection will zero its Z coordinates.

Definition at line 330 of file geometry.h.

References mrpt::math::TPlane::getAsPose3D(), and mrpt::math::project3D().

template<class T >
void mrpt::math::project3D ( const std::vector< T > &  objs,
const CPose3D newXYpose,
std::vector< T > &  newObjs 
)

Projects a set of 3D objects into the plane's base.

Definition at line 340 of file geometry.h.

References mrpt::math::project3D().

bool BASE_IMPEXP mrpt::math::RectanglesIntersection ( const double &  R1_x_min,
const double &  R1_x_max,
const double &  R1_y_min,
const double &  R1_y_max,
const double &  R2_x_min,
const double &  R2_x_max,
const double &  R2_y_min,
const double &  R2_y_max,
const double &  R2_pose_x,
const double &  R2_pose_y,
const double &  R2_pose_phi 
)

Returns wether two rotated rectangles intersect.

The first rectangle is not rotated and given by (R1_x_min,R1_x_max)-(R1_y_min,R1_y_max). The second rectangle is given is a similar way, but it is internally rotated according to the given coordinates translation (R2_pose_x,R2_pose_y,R2_pose_phi(radians)), relative to the coordinates system of rectangle 1.

template<typename VECTOR_LIKE , typename Precision , typename MATRIX_LIKE >
void mrpt::math::rodrigues_so3_exp ( const VECTOR_LIKE &  w,
const Precision  A,
const Precision  B,
MATRIX_LIKE &  R 
)
inline

Compute a rotation exponential using the Rodrigues Formula.

The rotation axis is given by $\vec{w}$, and the rotation angle must be computed using $ \theta = |\vec{w}|$. This is provided as a separate function primarily to allow fast and rough matrix exponentials using fast and rough approximations to A and B.

Parameters
wVector about which to rotate.
A$\frac{\sin \theta}{\theta}$
B$\frac{1 - \cos \theta}{\theta^2}$
RMatrix to hold the return value.
See Also
CPose3D
Note
Method from TooN (C) Tom Drummond (GNU GPL)

Definition at line 1123 of file geometry.h.

References ASSERT_EQUAL_.

bool BASE_IMPEXP mrpt::math::SegmentsIntersection ( const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  x3,
const double &  y3,
const double &  x4,
const double &  y4,
double &  ix,
double &  iy 
)

Returns the intersection point, and if it exists, between two segments.

bool BASE_IMPEXP mrpt::math::SegmentsIntersection ( const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  x3,
const double &  y3,
const double &  x4,
const double &  y4,
float &  ix,
float &  iy 
)

Returns the intersection point, and if it exists, between two segments.

void mrpt::math::setEpsilon ( double  nE)
inline

Changes the value of the geometric epsilon.

See Also
geometryEpsilon,getEpsilon

Definition at line 698 of file geometry.h.

template<class VECTOR , class MATRIX >
void mrpt::math::skew_symmetric3 ( const VECTOR &  v,
MATRIX &  M 
)
inline

Computes the 3x3 skew symmetric matrix from a 3-vector or 3-array:

\[ M([x ~ y ~ z]^\top) = \left( \begin{array}{c c c} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{array} \right) \]

.

Definition at line 805 of file geometry.h.

template<class VECTOR >
mrpt::math::CMatrixDouble33 mrpt::math::skew_symmetric3 ( const VECTOR &  v)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 814 of file geometry.h.

References ASSERT_.

template<class VECTOR , class MATRIX >
void mrpt::math::skew_symmetric3_neg ( const VECTOR &  v,
MATRIX &  M 
)
inline

Computes the negative version of a 3x3 skew symmetric matrix from a 3-vector or 3-array:

\[ -M([x ~ y ~ z]^\top) = \left( \begin{array}{c c c} 0 & z & -y \\ -z & 0 & x \\ y & -x & 0 \end{array} \right) \]

.

Definition at line 830 of file geometry.h.

Referenced by mrpt::math::vectorsAreParallel2D().

template<class VECTOR >
mrpt::math::CMatrixDouble33 mrpt::math::skew_symmetric3_neg ( const VECTOR &  v)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 839 of file geometry.h.

References ASSERT_.

template<typename T >
void mrpt::math::slerp ( const CQuaternion< T > &  q0,
const CQuaternion< T > &  q1,
const double  t,
CQuaternion< T > &  q 
)

SLERP interpolation between two quaternions.

Parameters
[in]q0The quaternion for t=0
[in]q1The quaternion for t=1
[in]tA "time" parameter, in the range [0,1].
[out]qThe output, interpolated quaternion.
Template Parameters
TThe type of the quaternion (e.g. float, double).
Exceptions
std::exceptionOnly in Debug, if t is not in the valid range.
See Also
http://en.wikipedia.org/wiki/Slerp

Definition at line 57 of file slerp.h.

References nanoflann::abs(), ASSERTDEB_, and mrpt::utils::square().

void BASE_IMPEXP mrpt::math::slerp ( const CPose3D q0,
const CPose3D q1,
const double  t,
CPose3D p 
)

SLERP interpolation between two 6D poses - like mrpt::math::slerp for quaternions, but interpolates the [X,Y,Z] coordinates as well.

Parameters
[in]p0The pose for t=0
[in]p1The pose for t=1
[in]tA "time" parameter, in the range [0,1].
[out]pThe output, interpolated pose.
Exceptions
std::exceptionOnly in Debug, if t is not in the valid range.
void BASE_IMPEXP mrpt::math::slerp ( const CPose3DQuat q0,
const CPose3DQuat q1,
const double  t,
CPose3DQuat p 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool BASE_IMPEXP mrpt::math::splitInConvexComponents ( const TPolygon2D &  poly,
vector< TPolygon2D > &  components 
)

Splits a 2D polygon into convex components.

bool BASE_IMPEXP mrpt::math::splitInConvexComponents ( const TPolygon3D &  poly,
vector< TPolygon3D > &  components 
)

Splits a 3D polygon into convex components.

Exceptions
std::logic_errorif the polygon can't be fit into a plane.
bool BASE_IMPEXP mrpt::math::traceRay ( const vector< TPolygonWithPlane > &  vec,
const mrpt::poses::CPose3D pose,
double &  dist 
)

Fast ray tracing method using polygons' properties.

See Also
CRenderizable::rayTrace
bool mrpt::math::traceRay ( const vector< TPolygon3D > &  vec,
const mrpt::poses::CPose3D pose,
double &  dist 
)
inline

Fast ray tracing method using polygons' properties.

See Also
CRenderizable::rayTrace

Definition at line 746 of file geometry.h.

template<class T , class U >
bool mrpt::math::vectorsAreParallel2D ( const T &  v1,
const U &  v2 
)
inline

Returns true if two 2D vectors are parallel.

The arguments may be points, arrays, etc.

Definition at line 849 of file geometry.h.

References mrpt::math::skew_symmetric3_neg(), and mrpt::math::UNINITIALIZED_MATRIX.

template<class T , class U >
bool mrpt::math::vectorsAreParallel3D ( const T &  v1,
const U &  v2 
)
inline

Returns true if two 3D vectors are parallel.

The arguments may be points, arrays, etc.

Definition at line 857 of file geometry.h.

References nanoflann::abs(), and mrpt::math::geometryEpsilon.

Variable Documentation

const unsigned char mrpt::math::GEOMETRIC_TYPE_LINE =2
const unsigned char mrpt::math::GEOMETRIC_TYPE_PLANE =4
const unsigned char mrpt::math::GEOMETRIC_TYPE_POINT =0
const unsigned char mrpt::math::GEOMETRIC_TYPE_POLYGON =3
const unsigned char mrpt::math::GEOMETRIC_TYPE_SEGMENT =1
const unsigned char mrpt::math::GEOMETRIC_TYPE_UNDEFINED =255
double BASE_IMPEXP mrpt::math::geometryEpsilon

Global epsilon to overcome small precision errors.

Referenced by mrpt::math::getEpsilon(), and mrpt::math::vectorsAreParallel3D().

Definition at line 638 of file lightweight_geom_data.h.

Definition at line 640 of file lightweight_geom_data.h.




Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013