struct mrpt::math::TSegment3D

3D segment, consisting of two points.

See also:

TSegment2D, TLine3D, TPlane, TPolygon3D, TPoint3D

#include <mrpt/math/TSegment3D.h>

struct TSegment3D

    TPoint3D point1;
    TPoint3D point2;

    // construction

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


    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;


TPoint3D point1

origin point

TPoint3D point2

final point


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

Constructor from both points.


Fast default constructor.

Initializes to garbage.

TSegment3D(const TSegment2D& s)

Constructor from 2D object.

Sets the z to zero.


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.