Struct TLine3D

Struct Documentation

struct TLine3D

3D line, represented by a base point and a director vector.

Public Functions

TLine3D() = default

Fast default constructor. Initializes to all zeros.

TLine3D(const TPoint3D &p1, const TPoint3D &p2)

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

See also

mrpt::math::getRegressionLine()

Throws:

std::logic_error – if both points are the same.

explicit TLine3D(const TSegment3D &s)

Constructor from 3D segment

explicit TLine3D(const TLine2D &l)

Constructor from 2D object. Zeroes the z.

bool contains(const TPoint3D &point) const

Check whether a point is inside the line

double distance(const TPoint3D &point) const

Absolute distance between the line and a point.

TPoint3D closestPointTo(const TPoint3D &p) const

Closest point to p along the line. It is computed as the intersection of this with the plane perpendicular to this that passes through p

Note

[New in MRPT 2.3.1]

std::optional<double> distance(const TLine3D &point, const mrpt::optional_ref<mrpt::math::TPoint3D> &outMidPoint = std::nullopt) const

Minimum distance between this and another line. The return will be std::nullopt if lines are parallel, or zero if they intersect, a positive number otherwise.

Note

New in MRPT 2.3.0

void unitarize()

Unitarize director vector.

inline void getDirectorVector(double (&vector)[3]) const

Get director vector

inline const TVector3D &getDirectorVector() const

Get director vector (may be NOT unitary if not set so by the user)

inline void getUnitaryDirectorVector(double (&vector)[3])

Unitarize and then get director vector.

void generate2DObject(TLine2D &l) const

Project into 2D space, discarding the Z coordinate.

Throws:

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]”

Note

[New in MRPT 2.1.0]

Public Members

TPoint3D pBase

Base point

TVector3D director = {.0, .0, .0}

Director vector

Public Static Functions

static TLine3D FromPointAndDirector(const TPoint3D &basePoint, const TVector3D &directorVector)

Static constructor from a point and a director vector.

Note

[New in MRPT 2.0.4]

static TLine3D FromTwoPoints(const TPoint3D &p1, const TPoint3D &p2)

Static constructor from two points.

See also

mrpt::math::getRegressionLine()

Note

[New in MRPT 2.0.4]