struct mrpt::math::TLine2D¶
2D line without bounds, represented by its equation \(Ax+By+C=0\).
See also:
TLine3D, TSegment2D, TPolygon2D, TPoint2D
#include <mrpt/math/TLine2D.h> struct TLine2D { // fields std::array<double, 3> coefs {{0, 0, 0}}; // construction TLine2D(const TPoint2D& p1, const TPoint2D& p2); TLine2D(const TSegment2D& s); TLine2D(); TLine2D(double A, double B, double C); TLine2D(const TLine3D& l); // methods double evaluatePoint(const TPoint2D& point) const; bool contains(const TPoint2D& point) const; double distance(const TPoint2D& point) const; double signedDistance(const TPoint2D& point) const; void getNormalVector(double(&) vector [2]) const; void unitarize(); void getUnitaryNormalVector(double(&) vector [2]); void getDirectorVector(double(&) vector [2]) const; void getUnitaryDirectorVector(double(&) vector [2]); void generate3DObject(TLine3D& l) const; void getAsPose2D(TPose2D& outPose) const; void getAsPose2DForcingOrigin( const TPoint2D& origin, TPose2D& outPose ) const; std::string asString() const; static TLine2D FromCoefficientsABC(double A, double B, double C); static TLine2D FromTwoPoints(const TPoint2D& p1, const TPoint2D& p2); };
Fields¶
std::array<double, 3> coefs {{0, 0, 0}}
Line coefficients, stored as an array: \(\left[A,B,C\right]\).
Construction¶
TLine2D(const TPoint2D& p1, const TPoint2D& p2)
Constructor from two points, through which the line will pass.
Parameters:
logic_error |
if both points are the same |
TLine2D(const TSegment2D& s)
Constructor from a segment.
TLine2D()
Fast default constructor.
Initializes to undefined values.
TLine2D(double A, double B, double C)
Constructor from line’s coefficients.
TLine2D(const TLine3D& l)
Construction from 3D object, discarding the Z.
Parameters:
std::logic_error |
if the line is normal to the XY plane. |
Methods¶
double evaluatePoint(const TPoint2D& point) const
Evaluate point in the line’s equation.
bool contains(const TPoint2D& point) const
Check whether a point is inside the line.
double distance(const TPoint2D& point) const
Distance from a given point.
double signedDistance(const TPoint2D& point) const
Distance with sign from a given point (sign indicates side).
void getNormalVector(double(&) vector [2]) const
Get line’s normal vector.
void unitarize()
Unitarize line’s normal vector.
void getUnitaryNormalVector(double(&) vector [2])
Get line’s normal vector after unitarizing line.
void getDirectorVector(double(&) vector [2]) const
Get line’s director vector.
void getUnitaryDirectorVector(double(&) vector [2])
Unitarize line and then get director vector.
void generate3DObject(TLine3D& l) const
Project into 3D space, setting the z to 0.
std::string asString() const
Returns “[A, B, C]”.
[New in MRPT 2.1.0]
static TLine2D FromCoefficientsABC(double A, double B, double C)
Static constructor from Ax+By+C=0 coefficients.
[New in MRPT 2.0.4]
static TLine2D FromTwoPoints(const TPoint2D& p1, const TPoint2D& p2)
Static constructor from two points.
[New in MRPT 2.0.4]