Class: QgsTriangle¶
-
class
qgis.core.
QgsTriangle
¶ Bases:
QgsPolygon
QgsTriangle(p1:
QgsPoint
, p2:QgsPoint
, p3:QgsPoint
) Construct aQgsTriangle
from threeQgsPointV2
.- Parameters
p1 – first point
p2 – second point
p3 – third point
QgsTriangle(p1:
QgsPointXY
, p2:QgsPointXY
, p3:QgsPointXY
) Construct aQgsTriangle
from threeQgsPoint
.- Parameters
p1 – first point
p2 – second point
p3 – third point
QgsTriangle(p1: Union[QPointF, QPoint], p2: Union[QPointF, QPoint], p3: Union[QPointF, QPoint]) Construct a
QgsTriangle
from three QPointF.- Parameters
p1 – first point
p2 – second point
p3 – third point
QgsTriangle(
QgsTriangle
)Triangle geometry type.
Methods
Inherited method not used.
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 the three angles of the triangle.
- param doc
The segment (defined by a
QgsLineString
) returned bisect the angle of a vertex to the opposite side.- rtype
QgsCurve
Center of the circumscribed circle of the triangle.
Circumscribed circle of the triangle.
Radius of the circumscribed circle of the triangle.
- rtype
QgsTriangle
- rtype
QgsTriangle
Inherited method not used.
- param wkbPtr
- param wkt
- rtype
str
Center of the inscribed circle of the triangle.
Inscribed circle of the triangle.
Radius of the inscribed circle of the triangle.
Inherited method not used.
Convenient method checking if the geometry is degenerate (have duplicate or colinear point(s)).
Is the triangle equilateral (three sides with the same length)?
Is the triangle isocele (two sides with the same length)?
Is the triangle right-angled?
Is the triangle scalene (all sides have different lengths)?
Returns the three lengths of the triangle.
Medial (or midpoint) triangle of a triangle ABC is the triangle with vertices at the midpoints of the triangle’s sides.
A median is a segment (defined by a
QgsLineString
) from a vertex to the midpoint of the opposite side.- param vId
An orthocenter is the point of intersection of the altitudes of a triangle.
- param ring
- rtype
QgsPolygon
- rtype
QgsCurvePolygon
Returns coordinates of a vertex.
-
addInteriorRing
(self, ring: QgsCurve)¶ Inherited method not used. You cannot add an interior ring into a triangle.
- Parameters
ring (QgsCurve) –
-
altitudes
(self) → object¶ 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).- Return type
object
- Returns
Three altitudes from this triangle. An empty list is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) [alt.asWkt() for alt in tri.altitudes()] # ['LineString (0 0, 0 5)', 'LineString (0 5, 2.5 2.5)', 'LineString (5 5, 0 5)'] QgsTriangle().altitudes() # []
-
angles
(self) → List[float]¶ Returns the three angles of the triangle.
- Return type
List[float]
- 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. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) [math.degrees(i) for i in tri.angles()] # [45.0, 90.0, 45.0] QgsTriangle().angles() # []
-
asGml3
(self, doc: QDomDocument, precision: int = 17, ns: str = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) → QDomElement¶ - Parameters
doc (QDomDocument) –
precision (int = 17) –
ns (str = '') –
axisOrder (QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) –
- Return type
QDomElement
-
bisectors
(self, lengthTolerance: float = 0.0001) → List[QgsLineString]¶ The segment (defined by a
QgsLineString
) returned bisect the angle of a vertex to the opposite side.- Parameters
lengthTolerance (float = 0.0001) – The tolerance to use.
- Return type
List[QgsLineString]
- Returns
Three angle bisector from this triangle. An empty list is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) [bis.asWkt() for bis in tri.bisectors()] # ['LineString (0 0, 2.07106781186547462 5)', 'LineString (0 5, 2.5 2.5)', 'LineString (5 5, 0 2.92893218813452538)'] QgsTriangle().bisectors() # []
-
calculateBoundingBox
()¶
-
childCount
()¶
-
childGeometry
()¶
-
childPoint
()¶
-
circumscribedCenter
(self) → QgsPoint¶ Center of the circumscribed circle of the triangle.
- Return type
- Returns
The center of the circumscribed circle of the triangle. An empty point is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.circumscribedCenter().asWkt() # 'Point (2.5 2.5)' QgsTriangle().circumscribedCenter().asWkt() # 'Point (0 0)'
-
circumscribedCircle
(self) → QgsCircle¶ Circumscribed circle of the triangle.
- Return type
- 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()
-
circumscribedRadius
(self) → float¶ Radius of the circumscribed circle of the triangle.
- Return type
float
- Returns
The radius of the circumscribed circle of the triangle. 0.0 is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.circumscribedRadius() # 3.5355339059327378 QgsTriangle().circumscribedRadius() # 0.0
-
clear
(self)¶
-
clearCache
()¶
-
clone
(self) → QgsTriangle¶ - Return type
-
createEmptyWithSameType
(self) → QgsTriangle¶ - Return type
-
deleteVertex
(self, position: QgsVertexId) → bool¶ Inherited method not used. You cannot delete or insert a vertex directly. Returns always false.
- Parameters
position (QgsVertexId) –
- Return type
bool
-
fromWkb
(self, wkbPtr: QgsConstWkbPtr) → bool¶ - Parameters
wkbPtr (QgsConstWkbPtr) –
- Return type
bool
-
fromWkt
(self, wkt: str) → bool¶ - Parameters
wkt (str) –
- Return type
bool
-
geometryType
(self) → str¶ - Return type
str
-
hasChildGeometries
()¶
-
inscribedCenter
(self) → QgsPoint¶ Center of the inscribed circle of the triangle. Z dimension is supported and is retrieved from the first 3D point amongst vertices.
- Return type
- Returns
The center of the inscribed circle of the triangle. An empty point is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.inscribedCenter().asWkt() # 'Point (1.46446609406726225 3.53553390593273775)' QgsTriangle().inscribedCenter().asWkt() # 'Point (0 0)'
-
inscribedCircle
(self) → QgsCircle¶ Inscribed circle of the triangle.
- Return type
- 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()
-
inscribedRadius
(self) → float¶ Radius of the inscribed circle of the triangle.
- Return type
float
- Returns
The radius of the inscribed circle of the triangle. 0.0 is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.inscribedRadius() # 1.4644660940672622 QgsTriangle().inscribedRadius() # 0.0
-
insertVertex
(self, position: QgsVertexId, vertex: QgsPoint) → bool¶ Inherited method not used. You cannot delete or insert a vertex directly. Returns always false.
- Parameters
position (QgsVertexId) –
vertex (QgsPoint) –
- Return type
bool
-
isDegenerate
(self) → bool¶ Convenient method checking if the geometry is degenerate (have duplicate or colinear point(s)).
- Return type
bool
- 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
-
isEquilateral
(self, lengthTolerance: float = 0.0001) → bool¶ Is the triangle equilateral (three sides with the same length)?
- Parameters
lengthTolerance (float = 0.0001) – The tolerance to use
- Return type
bool
- Returns
True or False. Always false for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 10, 10 ), QgsPoint( 16, 10 ), QgsPoint( 13, 15.1962 ) ) tri.lengths() # [6.0, 6.0000412031918575, 6.0000412031918575] tri.isEquilateral() # True # All lengths are close to 6.0 QgsTriangle().isEquilateral() # False
-
isIsocele
(self, lengthTolerance: float = 0.0001) → bool¶ Is the triangle isocele (two sides with the same length)?
- Parameters
lengthTolerance (float = 0.0001) – The tolerance to use
- Return type
bool
- Returns
True or False. Always false for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.lengths() # [5.0, 5.0, 7.0710678118654755] tri.isIsocele() # True # length of [AB] == length of [BC] QgsTriangle().isIsocele() # False
-
isRight
(self, angleTolerance: float = 0.0001) → bool¶ Is the triangle right-angled?
- Parameters
angleTolerance (float = 0.0001) – The tolerance to use
- Return type
bool
- Returns
True or False. Always false for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) [math.degrees(i) for i in tri.angles()] # [45.0, 90.0, 45.0] tri.isRight() # True # angle of ABC == 90 QgsTriangle().isRight() # False
-
isScalene
(self, lengthTolerance: float = 0.0001) → bool¶ Is the triangle scalene (all sides have different lengths)?
- Parameters
lengthTolerance (float = 0.0001) – The tolerance to use
- Return type
bool
- Returns
True or False. Always false for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 7.2825, 4.2368 ), QgsPoint( 13.0058, 3.3218 ), QgsPoint( 9.2145, 6.5242 ) ) tri.lengths() # [5.795980321740233, 4.962793714229921, 2.994131386562721] tri.isScalene() # True # All lengths are different QgsTriangle().isScalene() # False
-
lengths
(self) → List[float]¶ Returns the three lengths of the triangle.
- Return type
List[float]
- 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. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.lengths() # [5.0, 5.0, 7.0710678118654755] QgsTriangle().lengths() # []
-
medial
(self) → QgsTriangle¶ Medial (or midpoint) triangle of a triangle ABC is the triangle with vertices at the midpoints of the triangle’s sides.
- Return type
- Returns
The medial from this triangle. An empty triangle is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.medial().asWkt() # 'Triangle ((0 2.5, 2.5 5, 2.5 2.5, 0 2.5))' QgsTriangle().medial().asWkt() # 'Triangle ( )'
-
medians
(self) → List[QgsLineString]¶ A median is a segment (defined by a
QgsLineString
) from a vertex to the midpoint of the opposite side.- Return type
List[QgsLineString]
- Returns
Three medians from this triangle. An empty list is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) [med.asWkt() for med in tri.medians()] # ['LineString (0 0, 2.5 5)', 'LineString (0 5, 2.5 2.5)', 'LineString (5 5, 0 2.5)'] QgsTriangle().medians() # []
-
moveVertex
(self, vId: QgsVertexId, newPos: QgsPoint) → bool¶ - Parameters
vId (QgsVertexId) –
newPos (QgsPoint) –
- Return type
bool
-
orthocenter
(self, lengthTolerance: float = 0.0001) → QgsPoint¶ An orthocenter is the point of intersection of the altitudes of a triangle.
- Parameters
lengthTolerance (float = 0.0001) – The tolerance to use
- Return type
- Returns
The orthocenter of the triangle. An empty point is returned for empty triangle. * Example:
tri = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ) tri.orthocenter().asWkt() # 'Point (0 5)' QgsTriangle().orthocenter().asWkt() # 'Point (0 0)'
-
setZMTypeFromSubGeometry
()¶
-
surfaceToPolygon
(self) → QgsPolygon¶ - Return type
-
toCurveType
(self) → QgsCurvePolygon¶ - Return type