struct mrpt::math::TSegment3D

3D segment, consisting of two points.

See also:

TSegment2D, TLine3D, TPlane, TPolygon3D, TPoint3D

#include <mrpt/math/TSegment3D.h>

struct TSegment3D
{
    //
fields

    TPoint3D point1;
    TPoint3D point2;

    // construction

    TSegment3D();
    TSegment3D(const TPoint3D& p1, const TPoint3D& p2);
    TSegment3D(const TSegment2D& s);

    //
methods

    double length() const;
    double distance(const TPoint3D& point) const;
    double distance(const TSegment3D& segment) const;
    bool contains(const TPoint3D& point) const;
    TPoint3D& operator [] (size_t i);
    const TPoint3D& operator [] (size_t i) const;
    void generate2DObject(TSegment2D& s) const;
    void getCenter(TPoint3D& p) const;
    bool operator < (const TSegment3D& s) const;
    static TSegment3D FromPoints(const TPoint3D& p1, const TPoint3D& p2);
};

Fields

TPoint3D point1

origin point

TPoint3D point2

final point

Construction

TSegment3D()

Fast default constructor.

Initializes to (0,0,0)-(0,0,0)

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

Constructor from two points.

TSegment3D(const TSegment2D& s)

Constructor from 2D object.

Sets the z to zero

Methods

double length() const

Segment length.

double distance(const TPoint3D& point) const

Distance to point.

double distance(const TSegment3D& segment) const

Distance to another segment.

bool contains(const TPoint3D& point) const

Check whether a point is inside the segment.

TPoint3D& operator [] (size_t i)

Access to points using operator[0-1].

const TPoint3D& operator [] (size_t i) const

Access to points using operator[0-1].

void generate2DObject(TSegment2D& s) const

Projection into 2D space, discarding the z.

void getCenter(TPoint3D& p) const

Segment’s central point.

static TSegment3D FromPoints(const TPoint3D& p1, const TPoint3D& p2)

Static method, returns segment from two points.

New in MRPT 2.3.0