struct mrpt::math::TLine3D¶
3D line, represented by a base point and a director vector.
See also:
TLine2D, TSegment3D, TPlane, TPolygon3D, TPoint3D
#include <mrpt/math/TLine3D.h> struct TLine3D { // fields TPoint3D pBase; TVector3D director {.0, .0, .0}; // construction TLine3D(); TLine3D(const TPoint3D& p1, const TPoint3D& p2); TLine3D(const TSegment3D& s); TLine3D(const TLine2D& l); // methods bool contains(const TPoint3D& point) const; double distance(const TPoint3D& point) const; void unitarize(); void getDirectorVector(double(&) vector [3]) const; const TVector3D& getDirectorVector() const; void getUnitaryDirectorVector(double(&) vector [3]); void generate2DObject(TLine2D& l) const; std::string asString() const; static TLine3D FromPointAndDirector(const TPoint3D& basePoint, const TVector3D& directorVector); static TLine3D FromTwoPoints(const TPoint3D& p1, const TPoint3D& p2); };
Construction¶
TLine3D()
Fast default constructor.
Initializes to all zeros.
TLine3D(const TPoint3D& p1, const TPoint3D& p2)
Constructor from two points, through which the line will pass.
Parameters:
std::logic_error |
if both points are the same. |
TLine3D(const TSegment3D& s)
Constructor from 3D segment.
TLine3D(const TLine2D& l)
Constructor from 2D object.
Zeroes the z.
Methods¶
bool contains(const TPoint3D& point) const
Check whether a point is inside the line.
double distance(const TPoint3D& point) const
Distance between the line and a point.
void unitarize()
Unitarize director vector.
void getDirectorVector(double(&) vector [3]) const
Get director vector.
const TVector3D& getDirectorVector() const
Get director vector (may be NOT unitary if not set so by the user)
See also:
getUnitaryDirectorVector(), unitarize()
void getUnitaryDirectorVector(double(&) vector [3])
Unitarize and then get director vector.
void generate2DObject(TLine2D& l) const
Project into 2D space, discarding the Z coordinate.
Parameters:
std::logic_error |
if the line’s director vector is orthogonal to the XY plane. |
std::string asString() const
Returns “P=[x,y,z] u=[ux,uy,uz]”.
[New in MRPT 2.1.0]
static TLine3D FromPointAndDirector(const TPoint3D& basePoint, const TVector3D& directorVector)
Static constructor from a point and a director vector.
[New in MRPT 2.0.4]
static TLine3D FromTwoPoints(const TPoint3D& p1, const TPoint3D& p2)
Static constructor from two points.
[New in MRPT 2.0.4]