QgsLineSegment2D class
Represents a single 2D line segment, consisting of a 2D start and end vertex only.
Contents
Constructors, destructors, conversion operators
- QgsLineSegment2D(const QgsPointXY& start, const QgsPointXY& end)
- Constructor for a QgsLineSegment2D from the specified start point to the end point.
- QgsLineSegment2D(double x1, double y1, double x2, double y2)
- Constructor for a QgsLineSegment2D from the point (x1, y2) to (x2, y2).
Public functions
- auto end() const -> QgsPointXY
- Returns the segment's end point.
- auto endX() const -> double
- Returns the segment's end x-coordinate.
- auto endY() const -> double
- Returns the segment's end y-coordinate.
- auto length() const -> double
- Returns the length of the segment.
- auto lengthSquared() const -> double
- Returns the squared length of the segment.
- auto operator!=(const QgsLineSegment2D& other) const -> bool
- Inequality operator.
- auto operator==(const QgsLineSegment2D& other) const -> bool
- Equality operator.
- auto pointLeftOfLine(const QgsPointXY& point) const -> int
- Tests if a point is to the left of the line segment.
- void reverse()
- Reverses the line segment, so that the start and end points are flipped.
- void setEnd(const QgsPointXY& end)
- Sets the segment's end point.
- void setEndX(double x)
- Sets the segment's end x coordinate.
- void setEndY(double y)
- Sets the segment's end y coordinate.
- void setStart(const QgsPointXY& start)
- Sets the segment's start point.
- void setStartX(double x)
- Sets the segment's start x coordinate.
- void setStartY(double y)
- Sets the segment's start y coordinate.
- auto start() const -> QgsPointXY
- Returns the segment's start point.
- auto startX() const -> double
- Returns the segment's start x-coordinate.
- auto startY() const -> double
- Returns the segment's start y-coordinate.
Function documentation
QgsPointXY QgsLineSegment2D:: end() const
Returns the segment's end point.
double QgsLineSegment2D:: endX() const
Returns the segment's end x-coordinate.
double QgsLineSegment2D:: endY() const
Returns the segment's end y-coordinate.
double QgsLineSegment2D:: length() const
Returns the length of the segment.
double QgsLineSegment2D:: lengthSquared() const
Returns the squared length of the segment.
int QgsLineSegment2D:: pointLeftOfLine(const QgsPointXY& point) const
Tests if a point is to the left of the line segment.
Returns -1 if the point falls to the left of the line, or +1 if the point is to the right.
If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly on the line, or exactly in line with the segment) and the result is undefined.
void QgsLineSegment2D:: setEnd(const QgsPointXY& end)
Sets the segment's end point.
void QgsLineSegment2D:: setEndX(double x)
Sets the segment's end x coordinate.
void QgsLineSegment2D:: setEndY(double y)
Sets the segment's end y coordinate.
void QgsLineSegment2D:: setStart(const QgsPointXY& start)
Sets the segment's start point.
void QgsLineSegment2D:: setStartX(double x)
Sets the segment's start x coordinate.
void QgsLineSegment2D:: setStartY(double y)
Sets the segment's start y coordinate.
QgsPointXY QgsLineSegment2D:: start() const
Returns the segment's start point.
double QgsLineSegment2D:: startX() const
Returns the segment's start x-coordinate.
double QgsLineSegment2D:: startY() const
Returns the segment's start y-coordinate.