struct mrpt::math::TPlane

3D Plane, represented by its equation \(Ax+By+Cz+D=0\)

See also:

TSegment3D, TLine3D, TPolygon3D, TPoint3D

#include <mrpt/math/TPlane.h>

struct TPlane
{
    //
fields

    std::array<double, 4> coefs {{.0, .0, .0, .0}};

    // construction

    TPlane(const TPoint3D& p1, const TPoint3D& p2, const TPoint3D& p3);
    TPlane(const TPoint3D& p1, const TVector3D& normal);
    TPlane(const TPoint3D& p1, const TLine3D& r2);
    TPlane(const TLine3D& r1, const TLine3D& r2);
    TPlane();
    TPlane(double A, double B, double C, double D);
    TPlane(const double(&) vec [4]);

    //
methods

    double evaluatePoint(const TPoint3D& point) const;
    bool contains(const TPoint3D& point) const;
    bool contains(const TSegment3D& segment) const;
    bool contains(const TLine3D& line) const;
    double distance(const TPoint3D& point) const;
    double distance(const TLine3D& line) const;
    TVector3D getNormalVector() const;
    void unitarize();
    void getAsPose3D(mrpt::math::TPose3D& outPose) const;

    void getAsPose3DForcingOrigin(
        const TPoint3D& center,
        TPose3D& pose
        ) const;

    TPose3D getAsPose3DForcingOrigin(const TPoint3D& center) const;
    TVector3D getUnitaryNormalVector() const;
    std::string asString() const;
    static TPlane From3Points(const TPoint3D& p1, const TPoint3D& p2, const TPoint3D& p3);
    static TPlane FromPointAndNormal(const TPoint3D& p1, const TVector3D& normal);
    static TPlane FromPointAndLine(const TPoint3D& p1, const TLine3D& r);
    static TPlane FromTwoLines(const TLine3D& r1, const TLine3D& r2);
};

Fields

std::array<double, 4> coefs {{.0, .0, .0, .0}}

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

Construction

TPlane(const TPoint3D& p1, const TPoint3D& p2, const TPoint3D& p3)

Defines a plane which contains these three points.

Parameters:

std::logic_error

if the points are linearly dependants.

TPlane(const TPoint3D& p1, const TVector3D& normal)

Defines a plane given a point and a normal vector (must not be unit).

Parameters:

std::logic_error

if the normal vector is null

TPlane(const TPoint3D& p1, const TLine3D& r2)

Defines a plane which contains this point and this line.

Parameters:

std::logic_error

if the point is inside the line.

TPlane(const TLine3D& r1, const TLine3D& r2)

Defines a plane which contains the two lines.

Parameters:

std::logic_error

if the lines do not cross.

TPlane()

Fast default constructor.

Initializes to garbage.

TPlane(double A, double B, double C, double D)

Constructor from plane coefficients.

TPlane(const double(&) vec [4])

Constructor from an array of coefficients.

Methods

double evaluatePoint(const TPoint3D& point) const

Evaluate a point in the plane’s equation.

bool contains(const TPoint3D& point) const

Check whether a point is contained into the plane.

bool contains(const TSegment3D& segment) const

Check whether a segment is fully contained into the plane.

bool contains(const TLine3D& line) const

Check whether a line is fully contained into the plane.

double distance(const TPoint3D& point) const

Distance to 3D point.

double distance(const TLine3D& line) const

Distance to 3D line.

Will be zero if the line is not parallel to the plane.

TVector3D getNormalVector() const

Get plane’s normal vector.

void unitarize()

Unitarize normal vector.

TVector3D getUnitaryNormalVector() const

Get normal vector.

std::string asString() const

Returns “[A, B, C, D]”.

[New in MRPT 2.1.0]

static TPlane From3Points(const TPoint3D& p1, const TPoint3D& p2, const TPoint3D& p3)

[New in MRPT 2.1.0]

static TPlane FromPointAndNormal(const TPoint3D& p1, const TVector3D& normal)

[New in MRPT 2.1.0]

static TPlane FromPointAndLine(const TPoint3D& p1, const TLine3D& r)

Defines a plane which contains this point and this line.

[New in MRPT 2.1.0]

Parameters:

std::logic_error

if the point is inside the line.

static TPlane FromTwoLines(const TLine3D& r1, const TLine3D& r2)

Defines a plane which contains the two lines.

Parameters:

std::logic_error

if the lines do not cross.