Class LineSegment2D

Inheritance Relationships

Base Type

Derived Type

Class Documentation

class LineSegment2D : public tuw::Line2D

class to represent a 2D line with its endpoints and as equation a*x + b*y + c = 0

Subclassed by tuw::LineSegment2DDetector::LineSegment

Public Functions

LineSegment2D()

the lines endpoints

constructor

LineSegment2D(const LineSegment2D &l)

copy constructor

Parameters:

lLineSegment2D

LineSegment2D(const Point2D &p0, const Point2D &p1)

constructor to create a line from points

Parameters:
  • p0

  • p1

LineSegment2D(const double &x0, const double &y0, const double &x1, const double &y1)

constructor to create a line from points

Parameters:
  • x0

  • y0

  • x1

  • y1

const double &x0() const
Returns:

startpoint x

const double &y0() const
Returns:

startpoint y

const double &x1() const
Returns:

endpoint x

const double &y1() const
Returns:

endpoint y

double angle() const

orientation of the line in space @retun angle between -PI and PI

const Point2D &p0() const
Returns:

startpoint

const Point2D &p1() const
Returns:

endpoint

Point2D pc() const
Returns:

center point between p0 and p1

const Line2D &line() const
Returns:

the line function of the base class

double length() const
Returns:

length of the line

bool operator==(const LineSegment2D &o) const

comparison operator

comparison operator

Returns:

true on equal

Returns:

true on equal

LineSegment2D &set(const double &x0, const double &y0, const double &x1, const double &y1)

sets a line from points

Parameters:
  • x0

  • y0

  • x1

  • y1

LineSegment2D &set(const Point2D &p0, const Point2D &p1)

sets a line from points

Parameters:
  • p0

  • p1

double distanceTo(const Point2D &p, double &dx, double &dy) const

computes distance to line segment

Parameters:
  • p – point

  • dx – vector to point x

  • dx – vector to point y

Returns:

distance to line between the segment endpoints or the distance to the nearest endpoints

double distanceSqrTo(const Point2D &p, double &dx, double &dy) const

computes distance to line segment

computes squared distance to line segment

Parameters:
  • p – point

  • dx – vector to point x

  • dx – vector to point y

  • p – point

  • dx – vector to point x

  • dx – vector to point y

Returns:

distance to line between the segment endpoints or the distance to the nearest endpoints

Returns:

distance to line between the segment endpoints or the distance to the nearest endpoints

double closestPointLineSegmentRatio(const Point2D &p) const
Point2D closestPointTo(const Point2D &p) const

computes closest point along segment

Parameters:

p – point

Returns:

closest point along segment to the given point

double distanceTo(const Point2D &p) const

computes distance to line segment

computes distance to line segment

Parameters:

p – point

Returns:

distance to line between the segment endpoints or the distance to the nearest endpoints

Returns:

distance to line between the segment endpoints or the distance to the nearest endpoints

Protected Attributes

Point2D p0_
Point2D p1_

Friends

inline friend std::ostream &operator<<(std::ostream &os, const LineSegment2D &o)