Class LineSegment2D
Defined in File linesegment2d.hpp
Inheritance Relationships
Base Type
public tuw::Line2D
(Class Line2D)
Derived Type
public tuw::LineSegment2DDetector::LineSegment
(Class LineSegment2DDetector::LineSegment)
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:
l – LineSegment2D
-
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
-
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
See also
http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-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
See also
http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
See also
http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-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
-
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
See also
http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
See also
http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-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
Friends
-
inline friend std::ostream &operator<<(std::ostream &os, const LineSegment2D &o)
-
LineSegment2D()