datatypes::Line2D Class Reference

A line in the two-dimensional plane, composed out of two points. More...

`#include <Line2D.hpp>`

Inheritance diagram for datatypes::Line2D:

## Public Types | |

typedef Point2D | first_type |

Typedef for STL std::pair compatibility. | |

enum | IntersectingType { NotIntersecting, LineIntersecting, OutsideIntersecting } |

Describes how two lines can be intersecting. More... | |

typedef Point2D | second_type |

Typedef for STL std::pair compatibility. | |

typedef Point2D | value_type |

Typedef for STL compatibility. | |

## Public Member Functions | |

virtual const UINT32 | getUsedMemory () const |

Line2D () | |

Empty constructor. | |

Line2D (const Point2D &a, const Point2D &b) | |

Constructor with two points. | |

Line2D (float x1, float y1, float x2, float y2) | |

Constructor with x/y coordinates of the two points given explicitly. | |

Line2D (const std::pair< Point2D, Point2D > &p) | |

Constructor from a std::pair. | |

std::string | toString () |

Accessor methods for information about this line | |

bool | isZero () const |

Returns true if both points are zero. | |

const Point2D & | getP1 () const |

Returns the first point. | |

const Point2D & | getP2 () const |

Returns the second point. | |

Point2D | getCenterPoint () const |

Returns the point in the middle between first and second point. | |

double | getLength () const |

double | length () const |

double | getInclination () const |

double | inclination () const |

Point2D | getDiff () const |

Returns the difference between line end and line start as a Point2D. | |

Line2D | getUnitVector () const |

Returns a unit vector for this line. | |

Polygon2D | toPolygon2D () const |

Conversion to Polygon2D. | |

Polygon2D | toPolygon2D (unsigned samplePoints) const |

Conversion to Polygon2D with more than 2 sampling points. | |

Setter methods for changing this line | |

void | setP1 (const Point2D &p1) |

Sets the first point. | |

void | setP2 (const Point2D &p2) |

Sets the second point. | |

Geometrical relations to other objects | |

double | distanceToPoint (const Point2D &point) const |

Returns the distance of the given point to its orthogonal projection onto this line. | |

double | distanceFromLineSegment (const Point2D &point) const |

Returns the distance of a point to this line segment. | |

Point2D | projectOntoLine (const Point2D &point) const |

bool | containsPoint (const Point2D &point) const |

Returns true if this line "contains" the given point. | |

IntersectingType | isIntersecting (const Line2D &other, Point2D *intersectingPoint=NULL) const |

Calculates the intersection point between two lines. | |

## Static Public Member Functions | |

static Line2D | fromLinearRegression (const Polygon2D &points) |

Returns a Line2D from several points using linear regression. | |

## Private Attributes | |

Point2D | first |

The first point of this line. | |

Point2D | second |

The second point of this line. |

A line in the two-dimensional plane, composed out of two points.

This class is a line composed out of two points and offers some helper methods for simple geometrical calculations.

Definition at line 24 of file Line2D.hpp.

typedef Point2D datatypes::Line2D::first_type |

Typedef for STL std::pair compatibility.

Definition at line 30 of file Line2D.hpp.

Typedef for STL std::pair compatibility.

Definition at line 32 of file Line2D.hpp.

typedef Point2D datatypes::Line2D::value_type |

Typedef for STL compatibility.

Definition at line 28 of file Line2D.hpp.

Describes how two lines can be intersecting.

**See also:**- isIntersecting()

**Enumerator:**

Definition at line 35 of file Line2D.hpp.

datatypes::Line2D::Line2D | ( | ) | ` [inline]` |

Empty constructor.

Definition at line 44 of file Line2D.hpp.

datatypes::Line2D::Line2D | ( | const Point2D & | a, |

const Point2D & | b |
||

) | ` [inline]` |

Constructor with two points.

Definition at line 50 of file Line2D.hpp.

datatypes::Line2D::Line2D | ( | float | x1, |

float | y1, |
||

float | x2, |
||

float | y2 |
||

) | ` [inline]` |

Constructor with x/y coordinates of the two points given explicitly.

Definition at line 56 of file Line2D.hpp.

datatypes::Line2D::Line2D | ( | const std::pair< Point2D, Point2D > & | p | ) | ` [inline]` |

Constructor from a std::pair.

Definition at line 62 of file Line2D.hpp.

bool datatypes::Line2D::containsPoint | ( | const Point2D & | point | ) | const |

Returns true if this line "contains" the given point.

Computes the distance from the point to the line, and if it is zero, the point lies on the line and this method returns true.

Definition at line 75 of file Line2D.cpp.

double datatypes::Line2D::distanceFromLineSegment | ( | const Point2D & | point | ) | const |

Returns the distance of a point to this line segment.

If the point's projection onto the line is between the end points of this line, the distance to the projected point is returnd. If the projection is not on the line segment, the distance to the closest end point is returned. Alternatively, distanceToPoint() returns the distance to the point's projection in all cases.

Definition at line 110 of file Line2D.cpp.

double datatypes::Line2D::distanceToPoint | ( | const Point2D & | point | ) | const |

Returns the distance of the given point to its orthogonal projection onto this line.

The calculated distance is always the distance from the point to the point's projection onto the line, even if the point's projection is not between the end points of the line. Alternatively, distanceFromLineSegment() returns the distance to the line's end point in that case.

Definition at line 81 of file Line2D.cpp.

Line2D datatypes::Line2D::fromLinearRegression | ( | const Polygon2D & | points | ) | ` [static]` |

Returns a Line2D from several points using linear regression.

Definition at line 309 of file Line2D.cpp.

Point2D datatypes::Line2D::getCenterPoint | ( | ) | const |

Returns the point in the middle between first and second point.

Definition at line 339 of file Line2D.cpp.

Point2D datatypes::Line2D::getDiff | ( | ) | const` [inline]` |

Returns the difference between line end and line start as a Point2D.

Definition at line 109 of file Line2D.hpp.

double datatypes::Line2D::getInclination | ( | ) | const |

Calculates the rising angle of a line: the inclination angle. Returns a value in [-PI,PI] in radians.

Definition at line 42 of file Line2D.cpp.

double datatypes::Line2D::getLength | ( | ) | const` [inline]` |

Returns the length of this line, i.e. the distance of the two points.

Definition at line 93 of file Line2D.hpp.

const Point2D& datatypes::Line2D::getP1 | ( | ) | const` [inline]` |

Returns the first point.

Definition at line 83 of file Line2D.hpp.

const Point2D& datatypes::Line2D::getP2 | ( | ) | const` [inline]` |

Returns the second point.

Definition at line 86 of file Line2D.hpp.

Line2D datatypes::Line2D::getUnitVector | ( | ) | const |

Returns a unit vector for this line.

The returned unit vector has the same starting point as this line (which is getP1()) and it has a length of 1.0.

Definition at line 56 of file Line2D.cpp.

virtual const UINT32 datatypes::Line2D::getUsedMemory | ( | ) | const` [inline, virtual]` |

Implements datatypes::BasicData.

Definition at line 68 of file Line2D.hpp.

double datatypes::Line2D::inclination | ( | ) | const` [inline]` |

Deprecated. Calculates the rising angle of a line: the inclination angle. Returns a value in [-PI,PI] in radians.

Definition at line 105 of file Line2D.hpp.

Line2D::IntersectingType datatypes::Line2D::isIntersecting | ( | const Line2D & | other, |

Point2D * | intersectingPoint = `NULL` |
||

) | const |

Calculates the intersection point between two lines.

The returned value describes whether the two lines intersect within their line segments, or outside of their line segments, or not at all. The actual intersection point is written to intersectingPoint if that pointer is non-NULL.

Definition at line 258 of file Line2D.cpp.

bool datatypes::Line2D::isZero | ( | ) | const` [inline]` |

Returns true if both points are zero.

Definition at line 80 of file Line2D.hpp.

double datatypes::Line2D::length | ( | ) | const` [inline]` |

Deprecated. Returns the length of this line, i.e. the distance of the two points.

Definition at line 97 of file Line2D.hpp.

Point2D datatypes::Line2D::projectOntoLine | ( | const Point2D & | point | ) | const |

Calculates and returns the point that results when projecting the given point onto this line orthogonally.

Definition at line 91 of file Line2D.cpp.

void datatypes::Line2D::setP1 | ( | const Point2D & | p1 | ) | ` [inline]` |

Sets the first point.

Definition at line 131 of file Line2D.hpp.

void datatypes::Line2D::setP2 | ( | const Point2D & | p2 | ) | ` [inline]` |

Sets the second point.

Definition at line 134 of file Line2D.hpp.

Polygon2D datatypes::Line2D::toPolygon2D | ( | ) | const |

Conversion to Polygon2D.

Definition at line 17 of file Line2D.cpp.

Polygon2D datatypes::Line2D::toPolygon2D | ( | unsigned | samplePoints | ) | const |

Conversion to Polygon2D with more than 2 sampling points.

Definition at line 22 of file Line2D.cpp.

std::string datatypes::Line2D::toString | ( | ) |

Definition at line 66 of file Line2D.cpp.

Point2D datatypes::Line2D::first` [private]` |

The first point of this line.

Definition at line 193 of file Line2D.hpp.

Point2D datatypes::Line2D::second` [private]` |

The second point of this line.

Definition at line 195 of file Line2D.hpp.

The documentation for this class was generated from the following files:

libsick_ldmrs

Author(s): SICK AG, Martin Günther , Jochen Sprickerhof

autogenerated on Wed Jun 14 2017 04:04:51

Author(s): SICK AG

autogenerated on Wed Jun 14 2017 04:04:51