Struct TLine2D

Struct Documentation

struct TLine2D

2D line without bounds, represented by its equation \(Ax+By+C=0\).

Public Functions

TLine2D(const TPoint2D &p1, const TPoint2D &p2)

Constructor from two points, through which the line will pass.

See also

mrpt::math::getRegressionLine()

Throws:

logic_error – if both points are the same

explicit TLine2D(const TSegment2D &s)

Constructor from a segment

TLine2D() = default

Fast default constructor. Initializes to undefined values.

inline constexpr TLine2D(double A, double B, double C)

Constructor from line’s coefficients

explicit TLine2D(const TLine3D &l)

Construction from 3D object, discarding the Z.

Throws:

std::logic_error – if the line is normal to the XY plane.

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

Absolute 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.

inline void getUnitaryNormalVector(double (&vector)[2])

Get line’s normal vector after unitarizing line.

void getDirectorVector(double (&vector)[2]) const

Get line’s director vector.

inline 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.

void getAsPose2D(TPose2D &outPose) const
void getAsPose2DForcingOrigin(const TPoint2D &origin, TPose2D &outPose) const
std::string asString() const

Returns “[A, B, C]”

Note

[New in MRPT 2.1.0]

Note

Do not inherit from mrpt::Stringifyable to avoid virtual class table and keeping the class trivially-copiable.

Public Members

std::array<double, 3> coefs{{0, 0, 0}}

Line coefficients, stored as an array: \(\left[A,B,C\right]\)

Public Static Functions

static TLine2D FromCoefficientsABC(double A, double B, double C)

Static constructor from Ax+By+C=0 coefficients.

Note

[New in MRPT 2.0.4]

static TLine2D FromTwoPoints(const TPoint2D &p1, const TPoint2D &p2)

Static constructor from two points.

Note

[New in MRPT 2.0.4]