QgsTriangle class
Triangle geometry type.
Contents
Base classes
- class QgsPolygon
- Polygon geometry type.
Constructors, destructors, conversion operators
- QgsTriangle(const QgsPoint& p1, const QgsPoint& p2, const QgsPoint& p3)
- Construct a QgsTriangle from three QgsPointV2.
- QgsTriangle(const QgsPointXY& p1, const QgsPointXY& p2, const QgsPointXY& p3) explicit
- Construct a QgsTriangle from three QgsPoint.
- QgsTriangle(QPointF p1, QPointF p2, QPointF p3) explicit
- Construct a QgsTriangle from three QPointF.
Public functions
- void addInteriorRing(QgsCurve* ring) override
- Inherited method not used. You cannot add an interior ring into a triangle.
- auto altitudes() const -> QVector<QgsLineString>
- An altitude is a segment (defined by a QgsLineString) from a vertex to the opposite side (or, if necessary, to the extension of the opposite side).
- auto angles() const -> QVector<double>
- Returns the three angles of the triangle.
-
auto asGml3(QDomDocument& doc,
int precision = 17,
const QString& ns = "gml",
QgsAbstractGeometry::
AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY) const -> QDomElement override - Returns a GML3 representation of the geometry.
- auto bisectors(double lengthTolerance = 0.0001) const -> QVector<QgsLineString>
- The segment (defined by a QgsLineString) returned bisect the angle of a vertex to the opposite side.
- auto boundary() const -> QgsCurve* override
- Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry).
- auto cast(const QgsAbstractGeometry* geom) const -> const QgsTriangle*
- Cast the geom to a QgsTriangle.
- auto circumscribedCenter() const -> QgsPoint
- Center of the circumscribed circle of the triangle.
- auto circumscribedCircle() const -> QgsCircle
- Circumscribed circle of the triangle.
- auto circumscribedRadius() const -> double
- Radius of the circumscribed circle of the triangle.
- void clear() override
- Clears the geometry, ie reset it to a null geometry.
- auto clone() const -> QgsTriangle* override
- Clones the geometry by performing a deep copy.
- auto createEmptyWithSameType() const -> QgsTriangle* override
- Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
- auto deleteVertex(QgsVertexId position) -> bool override
- Inherited method not used. You cannot delete or insert a vertex directly. Returns always false.
- auto fromWkb(QgsConstWkbPtr& wkb) -> bool override
- Sets the geometry from a WKB string.
- auto fromWkt(const QString& wkt) -> bool override
- Sets the geometry from a WKT string.
- auto geometryType() const -> QString override
- Returns a unique string representing the geometry type.
- auto inscribedCenter() const -> QgsPoint
- Center of the inscribed circle of the triangle.
- auto inscribedCircle() const -> QgsCircle
- Inscribed circle of the triangle.
- auto inscribedRadius() const -> double
- Radius of the inscribed circle of the triangle.
- auto insertVertex(QgsVertexId position, const QgsPoint& vertex) -> bool override
- Inherited method not used. You cannot delete or insert a vertex directly. Returns always false.
- auto isDegenerate() -> bool
- Convenient method checking if the geometry is degenerate (have duplicate or colinear point(s)).
- auto isEquilateral(double lengthTolerance = 0.0001) const -> bool
- Is the triangle equilateral (three sides with the same length)?
- auto isIsocele(double lengthTolerance = 0.0001) const -> bool
- Is the triangle isocele (two sides with the same length)?
- auto isRight(double angleTolerance = 0.0001) const -> bool
- Is the triangle right-angled?
- auto isScalene(double lengthTolerance = 0.0001) const -> bool
- Is the triangle scalene (all sides have different lengths)?
- auto lengths() const -> QVector<double>
- Returns the three lengths of the triangle.
- auto medial() const -> QgsTriangle
- Medial (or midpoint) triangle of a triangle ABC is the triangle with vertices at the midpoints of the triangle's sides.
- auto medians() const -> QVector<QgsLineString>
- A median is a segment (defined by a QgsLineString) from a vertex to the midpoint of the opposite side.
- auto moveVertex(QgsVertexId position, const QgsPoint& newPos) -> bool override
- Moves a vertex within the geometry.
- auto orthocenter(double lengthTolerance = 0.0001) const -> QgsPoint
- An orthocenter is the point of intersection of the altitudes of a triangle.
- void setExteriorRing(QgsCurve* ring) override
- Sets the exterior ring of the polygon.
- void setInteriorRings(const QVector<QgsCurve*>& rings) deleted
- Inherited method not used.
- auto surfaceToPolygon() const -> QgsPolygon* override
- Gets a polygon representation of this surface.
- auto toCurveType() const -> QgsCurvePolygon* override
- Returns the geometry converted to the more generic curve type QgsCurvePolygon.
- auto vertexAt(int atVertex) const -> QgsPoint
- Returns coordinates of a vertex.
Function documentation
QgsTriangle:: QgsTriangle(const QgsPoint& p1,
const QgsPoint& p2,
const QgsPoint& p3)
Construct a QgsTriangle from three QgsPointV2.
| Parameters | |
|---|---|
| p1 | first point |
| p2 | second point |
| p3 | third point |
QgsTriangle:: QgsTriangle(const QgsPointXY& p1,
const QgsPointXY& p2,
const QgsPointXY& p3) explicit
Construct a QgsTriangle from three QgsPoint.
| Parameters | |
|---|---|
| p1 | first point |
| p2 | second point |
| p3 | third point |
QgsTriangle:: QgsTriangle(QPointF p1,
QPointF p2,
QPointF p3) explicit
Construct a QgsTriangle from three QPointF.
| Parameters | |
|---|---|
| p1 | first point |
| p2 | second point |
| p3 | third point |
QVector<QgsLineString> QgsTriangle:: altitudes() const
An altitude is a segment (defined by a QgsLineString) from a vertex to the opposite side (or, if necessary, to the extension of the opposite side).
| Returns | Three altitudes from this triangle. An empty list is returned for empty triangle.
|
|---|
QVector<double> QgsTriangle:: angles() const
Returns the three angles of the triangle.
| Returns | Angles in radians of triangle ABC where angle BAC is at 0, angle ABC is at 1, angle BCA is at 2. An empty list is returned for empty triangle.
|
|---|
QDomElement QgsTriangle:: asGml3(QDomDocument& doc,
int precision = 17,
const QString& ns = "gml",
QgsAbstractGeometry:: AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY) const override
Returns a GML3 representation of the geometry.
| Parameters | |
|---|---|
| doc | DOM document |
| precision | number of decimal places for coordinates |
| ns | XML namespace |
| axisOrder | Axis order for generated GML |
QVector<QgsLineString> QgsTriangle:: bisectors(double lengthTolerance = 0.0001) const
The segment (defined by a QgsLineString) returned bisect the angle of a vertex to the opposite side.
| Parameters | |
|---|---|
| lengthTolerance | The tolerance to use. |
| Returns | Three angle bisector from this triangle. An empty list is returned for empty triangle.
|
QgsCurve* QgsTriangle:: boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry).
| Returns | boundary for geometry. May be null for some geometry types. |
|---|
For instance, a polygon geometry will have a boundary consisting of the linestrings for each ring in the polygon.
const QgsTriangle* QgsTriangle:: cast(const QgsAbstractGeometry* geom) const
Cast the geom to a QgsTriangle.
Should be used by qgsgeometry_cast<QgsTriangle *>( geometry ).
QgsPoint QgsTriangle:: circumscribedCenter() const
Center of the circumscribed circle of the triangle.
| Returns | The center of the circumscribed circle of the triangle. An empty point is returned for empty triangle.
|
|---|
QgsCircle QgsTriangle:: circumscribedCircle() const
Circumscribed circle of the triangle.
| Returns | The circumbscribed of the triangle with a QgsCircle. An empty circle is returned for empty triangle. Example: tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.circumscribedCircle() # QgsCircle(Point (2.5 2.5), 3.5355339059327378, 0) QgsTriangle().circumscribedCircle() # QgsCircle() |
|---|
double QgsTriangle:: circumscribedRadius() const
Radius of the circumscribed circle of the triangle.
| Returns | The radius of the circumscribed circle of the triangle. 0.0 is returned for empty triangle.
|
|---|
QgsTriangle* QgsTriangle:: createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
To create it, the geometry is default constructed and then the WKB is changed.
bool QgsTriangle:: fromWkb(QgsConstWkbPtr& wkb) override
Sets the geometry from a WKB string.
After successful read the wkb argument will be at the position where the reading has stopped.
bool QgsTriangle:: fromWkt(const QString& wkt) override
Sets the geometry from a WKT string.
QString QgsTriangle:: geometryType() const override
Returns a unique string representing the geometry type.
QgsPoint QgsTriangle:: inscribedCenter() const
Center of the inscribed circle of the triangle.
| Returns | The center of the inscribed circle of the triangle. An empty point is returned for empty triangle.
|
|---|
Z dimension is supported and is retrieved from the first 3D point amongst vertices.
QgsCircle QgsTriangle:: inscribedCircle() const
Inscribed circle of the triangle.
| Returns | The inscribed of the triangle with a QgsCircle. An empty circle is returned for empty triangle. Example: tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.inscribedCircle() # QgsCircle(Point (1.46446609406726225 3.53553390593273775), 1.4644660940672622, 0) QgsTriangle().inscribedCircle() # QgsCircle() |
|---|
double QgsTriangle:: inscribedRadius() const
Radius of the inscribed circle of the triangle.
| Returns | The radius of the inscribed circle of the triangle. 0.0 is returned for empty triangle.
|
|---|
bool QgsTriangle:: isDegenerate()
Convenient method checking if the geometry is degenerate (have duplicate or colinear point(s)).
| Returns | True if the triangle is degenerate or empty, otherwise false. Example: tri = QgsTriangle() tri.isDegenerate() # True tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.isDegenerate() # False tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 5, 5 ), QgsPoint( 10, 10 ) ) tri.isDegenerate() # True tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ), QgsPoint( 5, 5 ) ) tri.isDegenerate() # True |
|---|
bool QgsTriangle:: isEquilateral(double lengthTolerance = 0.0001) const
Is the triangle equilateral (three sides with the same length)?
| Parameters | |
|---|---|
| lengthTolerance | The tolerance to use |
| Returns | True or False. Always false for empty triangle.
|
bool QgsTriangle:: isIsocele(double lengthTolerance = 0.0001) const
Is the triangle isocele (two sides with the same length)?
| Parameters | |
|---|---|
| lengthTolerance | The tolerance to use |
| Returns | True or False. Always false for empty triangle.
|
bool QgsTriangle:: isRight(double angleTolerance = 0.0001) const
Is the triangle right-angled?
| Parameters | |
|---|---|
| angleTolerance | The tolerance to use |
| Returns | True or False. Always false for empty triangle.
|
bool QgsTriangle:: isScalene(double lengthTolerance = 0.0001) const
Is the triangle scalene (all sides have different lengths)?
| Parameters | |
|---|---|
| lengthTolerance | The tolerance to use |
| Returns | True or False. Always false for empty triangle.
|
QVector<double> QgsTriangle:: lengths() const
Returns the three lengths of the triangle.
| Returns | Lengths of triangle ABC where [AB] is at 0, [BC] is at 1, [CA] is at 2. An empty list is returned for empty triangle.
|
|---|
QgsTriangle QgsTriangle:: medial() const
Medial (or midpoint) triangle of a triangle ABC is the triangle with vertices at the midpoints of the triangle's sides.
| Returns | The medial from this triangle. An empty triangle is returned for empty triangle.
|
|---|
QVector<QgsLineString> QgsTriangle:: medians() const
A median is a segment (defined by a QgsLineString) from a vertex to the midpoint of the opposite side.
| Returns | Three medians from this triangle. An empty list is returned for empty triangle.
|
|---|
bool QgsTriangle:: moveVertex(QgsVertexId position,
const QgsPoint& newPos) override
Moves a vertex within the geometry.
| Parameters | |
|---|---|
| position | vertex id for vertex to move |
| newPos | new position of vertex |
| Returns | true if move was successful |
QgsPoint QgsTriangle:: orthocenter(double lengthTolerance = 0.0001) const
An orthocenter is the point of intersection of the altitudes of a triangle.
| Parameters | |
|---|---|
| lengthTolerance | The tolerance to use |
| Returns | The orthocenter of the triangle. An empty point is returned for empty triangle.
|
void QgsTriangle:: setExteriorRing(QgsCurve* ring) override
Sets the exterior ring of the polygon.
| Parameters | |
|---|---|
| ring | new exterior ring. Ownership is transferred to the CurvePolygon. |
The CurvePolygon type will be updated to match the dimensionality of the exterior ring. For instance, setting a 2D exterior ring on a 3D CurvePolygon will drop the z dimension from the CurvePolygon and all interior rings.
void QgsTriangle:: setInteriorRings(const QVector<QgsCurve*>& rings) deleted
Inherited method not used.
You cannot add an interior ring into a triangle.
QgsPolygon* QgsTriangle:: surfaceToPolygon() const override
Gets a polygon representation of this surface.
Ownership is transferred to the caller.
QgsCurvePolygon* QgsTriangle:: toCurveType() const override
Returns the geometry converted to the more generic curve type QgsCurvePolygon.
| Returns | the converted geometry. Caller takes ownership |
|---|
QgsPoint QgsTriangle:: vertexAt(int atVertex) const
Returns coordinates of a vertex.
| Parameters | |
|---|---|
| atVertex | index of the vertex |
| Returns | Coordinates of the vertex or QgsPoint(0,0) on error (atVertex < 0 or > 3). |