QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsLineSegment2D Class Reference

Represents a single 2D line segment, consisting of a 2D start and end vertex only. More...

#include <qgslinesegment.h>

Public Member Functions

 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).
 
QgsPointXY end () const
 Returns the segment's end point.
 
double endX () const
 Returns the segment's end x-coordinate.
 
double endY () const
 Returns the segment's end y-coordinate.
 
double length () const
 Returns the length of the segment.
 
double lengthSquared () const
 Returns the squared length of the segment.
 
bool operator!= (const QgsLineSegment2D &other) const
 
bool operator== (const QgsLineSegment2D &other) const
 
int pointLeftOfLine (const QgsPointXY &point) const
 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.
 
QgsPointXY start () const
 Returns the segment's start point.
 
double startX () const
 Returns the segment's start x-coordinate.
 
double startY () const
 Returns the segment's start y-coordinate.
 

Detailed Description

Represents a single 2D line segment, consisting of a 2D start and end vertex only.

Since
QGIS 3.2

Definition at line 31 of file qgslinesegment.h.

Constructor & Destructor Documentation

◆ QgsLineSegment2D() [1/2]

QgsLineSegment2D::QgsLineSegment2D ( const QgsPointXY start,
const QgsPointXY end 
)
inline

Constructor for a QgsLineSegment2D from the specified start point to the end point.

Definition at line 40 of file qgslinesegment.h.

◆ QgsLineSegment2D() [2/2]

QgsLineSegment2D::QgsLineSegment2D ( double  x1,
double  y1,
double  x2,
double  y2 
)
inline

Constructor for a QgsLineSegment2D from the point (x1, y2) to (x2, y2).

Definition at line 49 of file qgslinesegment.h.

Member Function Documentation

◆ end()

QgsPointXY QgsLineSegment2D::end ( ) const
inline

Returns the segment's end point.

See also
start()
endX()
endY()

Definition at line 129 of file qgslinesegment.h.

◆ endX()

double QgsLineSegment2D::endX ( ) const
inline

Returns the segment's end x-coordinate.

See also
end()
endY()

Definition at line 97 of file qgslinesegment.h.

◆ endY()

double QgsLineSegment2D::endY ( ) const
inline

Returns the segment's end y-coordinate.

See also
end()
endX()

Definition at line 107 of file qgslinesegment.h.

◆ length()

double QgsLineSegment2D::length ( ) const
inline

Returns the length of the segment.

See also
lengthSquared()

Definition at line 58 of file qgslinesegment.h.

◆ lengthSquared()

double QgsLineSegment2D::lengthSquared ( ) const
inline

Returns the squared length of the segment.

See also
length()

Definition at line 67 of file qgslinesegment.h.

◆ operator!=()

bool QgsLineSegment2D::operator!= ( const QgsLineSegment2D other) const
inline

Definition at line 228 of file qgslinesegment.h.

◆ operator==()

bool QgsLineSegment2D::operator== ( const QgsLineSegment2D other) const
inline

Definition at line 223 of file qgslinesegment.h.

◆ pointLeftOfLine()

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.

See also
QgsGeometryUtils::leftOfLine()

Definition at line 21 of file qgslinesegment.cpp.

◆ reverse()

void QgsLineSegment2D::reverse ( )
inline

Reverses the line segment, so that the start and end points are flipped.

Definition at line 216 of file qgslinesegment.h.

◆ setEnd()

void QgsLineSegment2D::setEnd ( const QgsPointXY end)
inline

Sets the segment's end point.

See also
setEndX()
setEndY()
setStart()

Definition at line 195 of file qgslinesegment.h.

◆ setEndX()

void QgsLineSegment2D::setEndX ( double  x)
inline

Sets the segment's end x coordinate.

See also
setStartX()
setEnd()
setEndY()

Definition at line 162 of file qgslinesegment.h.

◆ setEndY()

void QgsLineSegment2D::setEndY ( double  y)
inline

Sets the segment's end y coordinate.

See also
setStartY()
setEnd()
setEndX()

Definition at line 173 of file qgslinesegment.h.

◆ setStart()

void QgsLineSegment2D::setStart ( const QgsPointXY start)
inline

Sets the segment's start point.

See also
setStartX()
setStartY()
setEnd()

Definition at line 184 of file qgslinesegment.h.

◆ setStartX()

void QgsLineSegment2D::setStartX ( double  x)
inline

Sets the segment's start x coordinate.

See also
setEndX()
setStart()
setStartY()

Definition at line 140 of file qgslinesegment.h.

◆ setStartY()

void QgsLineSegment2D::setStartY ( double  y)
inline

Sets the segment's start y coordinate.

See also
setEndY()
setStart()
setStartX()

Definition at line 151 of file qgslinesegment.h.

◆ start()

QgsPointXY QgsLineSegment2D::start ( ) const
inline

Returns the segment's start point.

See also
end()
startX()
startY()

Definition at line 118 of file qgslinesegment.h.

◆ startX()

double QgsLineSegment2D::startX ( ) const
inline

Returns the segment's start x-coordinate.

See also
start()
startY()

Definition at line 77 of file qgslinesegment.h.

◆ startY()

double QgsLineSegment2D::startY ( ) const
inline

Returns the segment's start y-coordinate.

See also
start()
startX()

Definition at line 87 of file qgslinesegment.h.


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