|
QGIS API Documentation 3.99.0-Master (2fe06baccd8)
|
Regular Polygon geometry type. More...
#include <qgsregularpolygon.h>
Public Types | |
| enum | ConstructionOption { InscribedCircle , CircumscribedCircle } |
| A regular polygon can be constructed inscribed in a circle or circumscribed about a circle. More... | |
Public Member Functions | |
| QgsRegularPolygon ()=default | |
| Constructor for QgsRegularPolygon. | |
| QgsRegularPolygon (const QgsPoint ¢er, const QgsPoint &pt1, unsigned int numberSides, ConstructionOption circle) | |
| Constructs a regular polygon by center and another point. | |
| QgsRegularPolygon (const QgsPoint ¢er, double radius, double azimuth, unsigned int numberSides, ConstructionOption circle) | |
| Constructs a regular polygon by center and parameters for the first vertex. | |
| QgsRegularPolygon (const QgsPoint &pt1, const QgsPoint &pt2, unsigned int numberSides) | |
| Constructs a regular polygon by two points of the first side. | |
| double | apothem () const |
| Returns the apothem of the regular polygon. | |
| double | area () const |
| Returns the area. | |
| QgsPoint | center () const |
| Returns the center point of the regular polygon. | |
| double | centralAngle () const |
| Returns the measure of the central angle (the angle subtended at the center of the polygon by one of its sides) in degrees. | |
| QgsCircle | circumscribedCircle () const |
| Returns the circumscribed circle. | |
| QgsPoint | firstVertex () const |
| Returns the first vertex (corner) of the regular polygon. | |
| QgsCircle | inscribedCircle () const |
| Returns the inscribed circle. | |
| double | interiorAngle () const |
| Returns the measure of the interior angles in degrees. | |
| bool | isEmpty () const |
| A regular polygon is empty if radius equal to 0 or number of sides < 3. | |
| double | length () const |
| Returns the length of a side. | |
| unsigned int | numberSides () const |
| Returns the number of sides of the regular polygon. | |
| bool | operator!= (const QgsRegularPolygon &rp) const |
| bool | operator== (const QgsRegularPolygon &rp) const |
| double | perimeter () const |
| Returns the perimeter. | |
| QgsPointSequence | points () const |
| Returns a list including the vertices of the regular polygon. | |
| double | radius () const |
| Returns the radius. | |
| void | setCenter (const QgsPoint ¢er) |
| Sets the center point. | |
| void | setFirstVertex (const QgsPoint &firstVertex) |
| Sets the first vertex. | |
| void | setNumberSides (unsigned int numberSides) |
| Sets the number of sides. | |
| void | setRadius (double radius) |
| Sets the radius. | |
| QgsLineString * | toLineString () const |
| Returns as a linestring. | |
| QgsPolygon * | toPolygon () const |
| Returns as a polygon. | |
| QString | toString (int pointPrecision=17, int radiusPrecision=17, int anglePrecision=2) const |
| Returns a string representation of the regular polygon. | |
| QgsTriangle | toTriangle () const |
| Returns as a triangle. | |
| QVector< QgsTriangle > | triangulate () const |
| Returns a triangulation (vertices from sides to the center) of the regular polygon. | |
Regular Polygon geometry type.
A regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length). The regular polygon is defined by a center point with a number of sides/vertices, a radius and the first vertex.
Definition at line 39 of file qgsregularpolygon.h.
A regular polygon can be constructed inscribed in a circle or circumscribed about a circle.
Definition at line 47 of file qgsregularpolygon.h.
|
default |
Constructor for QgsRegularPolygon.
| QgsRegularPolygon::QgsRegularPolygon | ( | const QgsPoint & | center, |
| double | radius, | ||
| double | azimuth, | ||
| unsigned int | numberSides, | ||
| ConstructionOption | circle ) |
Constructs a regular polygon by center and parameters for the first vertex.
An empty regular polygon is returned if numberSides < 3 or ConstructionOption isn't valid.
| center | The center of the regular polygon. |
| radius | Distance from the center and the first vertex or sides (see ConstructionOption). |
| azimuth | Angle in degrees started from the North to the first vertex. |
| numberSides | Number of sides of the regular polygon. |
| circle | Option to create the polygon. |
Definition at line 24 of file qgsregularpolygon.cpp.
| QgsRegularPolygon::QgsRegularPolygon | ( | const QgsPoint & | center, |
| const QgsPoint & | pt1, | ||
| unsigned int | numberSides, | ||
| ConstructionOption | circle ) |
Constructs a regular polygon by center and another point.
| center | The center of the regular polygon. |
| pt1 | The first vertex if the polygon is inscribed in circle or the midpoint of a side if the polygon is circumscribed about circle. |
| numberSides | Number of sides of the regular polygon. |
| circle | Option to create the polygon inscribed in circle (the radius is the distance between the center and vertices) or circumscribed about circle (the radius is the distance from the center to the midpoints of the sides). |
Definition at line 53 of file qgsregularpolygon.cpp.
| QgsRegularPolygon::QgsRegularPolygon | ( | const QgsPoint & | pt1, |
| const QgsPoint & | pt2, | ||
| unsigned int | numberSides ) |
Constructs a regular polygon by two points of the first side.
| pt1 | The first vertex of the first side, also first vertex of the regular polygon. |
| pt2 | The second vertex of the first side. |
| numberSides | Number of sides of the regular polygon. |
Definition at line 82 of file qgsregularpolygon.cpp.
|
inline |
Returns the apothem of the regular polygon.
The apothem is the radius of the inscribed circle.
Definition at line 116 of file qgsregularpolygon.h.
| double QgsRegularPolygon::area | ( | ) | const |
Returns the area.
Returns 0 if the regular polygon is empty.
Definition at line 278 of file qgsregularpolygon.cpp.
|
inline |
Returns the center point of the regular polygon.
Definition at line 95 of file qgsregularpolygon.h.
| double QgsRegularPolygon::centralAngle | ( | ) | const |
Returns the measure of the central angle (the angle subtended at the center of the polygon by one of its sides) in degrees.
Definition at line 328 of file qgsregularpolygon.cpp.
| QgsCircle QgsRegularPolygon::circumscribedCircle | ( | ) | const |
Returns the circumscribed circle.
Definition at line 255 of file qgsregularpolygon.cpp.
|
inline |
Returns the first vertex (corner) of the regular polygon.
Definition at line 109 of file qgsregularpolygon.h.
| QgsCircle QgsRegularPolygon::inscribedCircle | ( | ) | const |
Returns the inscribed circle.
Definition at line 249 of file qgsregularpolygon.cpp.
| double QgsRegularPolygon::interiorAngle | ( | ) | const |
Returns the measure of the interior angles in degrees.
Definition at line 323 of file qgsregularpolygon.cpp.
| bool QgsRegularPolygon::isEmpty | ( | ) | const |
A regular polygon is empty if radius equal to 0 or number of sides < 3.
Definition at line 115 of file qgsregularpolygon.cpp.
| double QgsRegularPolygon::length | ( | ) | const |
Returns the length of a side.
Returns 0 if the regular polygon is empty.
Definition at line 298 of file qgsregularpolygon.cpp.
|
inline |
Returns the number of sides of the regular polygon.
Definition at line 122 of file qgsregularpolygon.h.
| bool QgsRegularPolygon::operator!= | ( | const QgsRegularPolygon & | rp | ) | const |
Definition at line 110 of file qgsregularpolygon.cpp.
| bool QgsRegularPolygon::operator== | ( | const QgsRegularPolygon & | rp | ) | const |
Definition at line 102 of file qgsregularpolygon.cpp.
| double QgsRegularPolygon::perimeter | ( | ) | const |
Returns the perimeter.
Returns 0 if the regular polygon is empty.
Definition at line 288 of file qgsregularpolygon.cpp.
| QgsPointSequence QgsRegularPolygon::points | ( | ) | const |
Returns a list including the vertices of the regular polygon.
Definition at line 156 of file qgsregularpolygon.cpp.
|
inline |
Returns the radius.
This is also the radius of the circumscribing circle.
Definition at line 103 of file qgsregularpolygon.h.
| void QgsRegularPolygon::setCenter | ( | const QgsPoint & | center | ) |
Sets the center point.
Radius is unchanged. The first vertex is reprojected from the new center.
Definition at line 124 of file qgsregularpolygon.cpp.
| void QgsRegularPolygon::setFirstVertex | ( | const QgsPoint & | firstVertex | ) |
Sets the first vertex.
Radius is unchanged. The center is reprojected from the new first vertex.
Definition at line 140 of file qgsregularpolygon.cpp.
| void QgsRegularPolygon::setNumberSides | ( | unsigned int | numberSides | ) |
Sets the number of sides.
If numberSides < 3, the number of sides is unchanged.
Definition at line 148 of file qgsregularpolygon.cpp.
| void QgsRegularPolygon::setRadius | ( | double | radius | ) |
Sets the radius.
Center is unchanged. The first vertex is reprojected from the center with the new radius.
Definition at line 132 of file qgsregularpolygon.cpp.
| QgsLineString * QgsRegularPolygon::toLineString | ( | ) | const |
Returns as a linestring.
Definition at line 197 of file qgsregularpolygon.cpp.
| QgsPolygon * QgsRegularPolygon::toPolygon | ( | ) | const |
Returns as a polygon.
Definition at line 184 of file qgsregularpolygon.cpp.
| QString QgsRegularPolygon::toString | ( | int | pointPrecision = 17, |
| int | radiusPrecision = 17, | ||
| int | anglePrecision = 2 ) const |
Returns a string representation of the regular polygon.
Members will be truncated to the specified precision.
Definition at line 261 of file qgsregularpolygon.cpp.
| QgsTriangle QgsRegularPolygon::toTriangle | ( | ) | const |
Returns as a triangle.
An empty triangle is returned if the regular polygon is empty or if the number of sides is different from 3.
Definition at line 214 of file qgsregularpolygon.cpp.
| QVector< QgsTriangle > QgsRegularPolygon::triangulate | ( | ) | const |
Returns a triangulation (vertices from sides to the center) of the regular polygon.
An empty list is returned if the regular polygon is empty.
Definition at line 227 of file qgsregularpolygon.cpp.