QGIS API Documentation  3.20.0-Odense (decaadbb31)
Public Types | Public Member Functions | List of all members
QgsRegularPolygon Class Reference

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 () SIP_HOLDGIL=default
 Constructor for QgsRegularPolygon. More...
 
 QgsRegularPolygon (const QgsPoint &center, const QgsPoint &pt1, unsigned int numberSides, ConstructionOption circle) SIP_HOLDGIL
 Constructs a regular polygon by center and another point. More...
 
 QgsRegularPolygon (const QgsPoint &center, double radius, double azimuth, unsigned int numberSides, ConstructionOption circle) SIP_HOLDGIL
 Constructs a regular polygon by center and parameters for the first vertex. More...
 
 QgsRegularPolygon (const QgsPoint &pt1, const QgsPoint &pt2, unsigned int numberSides) SIP_HOLDGIL
 Constructs a regular polygon by two points of the first side. More...
 
double apothem () const SIP_HOLDGIL
 Returns the apothem of the regular polygon. More...
 
double area () const SIP_HOLDGIL
 Returns the area. More...
 
QgsPoint center () const SIP_HOLDGIL
 Returns the center point of the regular polygon. More...
 
double centralAngle () const SIP_HOLDGIL
 Returns the measure of the central angle (the angle subtended at the center of the polygon by one of its sides) in degrees. More...
 
QgsCircle circumscribedCircle () const SIP_HOLDGIL
 Returns the circumscribed circle. More...
 
QgsPoint firstVertex () const SIP_HOLDGIL
 Returns the first vertex (corner) of the regular polygon. More...
 
QgsCircle inscribedCircle () const SIP_HOLDGIL
 Returns the inscribed circle. More...
 
double interiorAngle () const SIP_HOLDGIL
 Returns the measure of the interior angles in degrees. More...
 
bool isEmpty () const SIP_HOLDGIL
 A regular polygon is empty if radius equal to 0 or number of sides < 3. More...
 
double length () const SIP_HOLDGIL
 Returns the length of a side. More...
 
unsigned int numberSides () const SIP_HOLDGIL
 Returns the number of sides of the regular polygon. More...
 
bool operator!= (const QgsRegularPolygon &rp) const SIP_HOLDGIL
 
bool operator== (const QgsRegularPolygon &rp) const SIP_HOLDGIL
 
double perimeter () const SIP_HOLDGIL
 Returns the perimeter. More...
 
QgsPointSequence points () const
 Returns a list including the vertices of the regular polygon. More...
 
double radius () const SIP_HOLDGIL
 Returns the radius. More...
 
void setCenter (const QgsPoint &center) SIP_HOLDGIL
 Sets the center point. More...
 
void setFirstVertex (const QgsPoint &firstVertex) SIP_HOLDGIL
 Sets the first vertex. More...
 
void setNumberSides (unsigned int numberSides) SIP_HOLDGIL
 Sets the number of sides. More...
 
void setRadius (double radius) SIP_HOLDGIL
 Sets the radius. More...
 
QgsLineStringtoLineString () const
 Returns as a linestring. More...
 
QgsPolygontoPolygon () const
 Returns as a polygon. More...
 
QString toString (int pointPrecision=17, int radiusPrecision=17, int anglePrecision=2) const
 Returns a string representation of the regular polygon. More...
 
QgsTriangle toTriangle () const
 Returns as a triangle. More...
 
QVector< QgsTriangletriangulate () const
 Returns a triangulation (vertices from sides to the center) of the regular polygon. More...
 

Detailed Description

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.

Since
QGIS 3.0

Definition at line 41 of file qgsregularpolygon.h.

Member Enumeration Documentation

◆ ConstructionOption

A regular polygon can be constructed inscribed in a circle or circumscribed about a circle.

Enumerator
InscribedCircle 

Inscribed in a circle (the radius is the distance between the center and vertices)

CircumscribedCircle 

Circumscribed about a circle (the radius is the distance from the center to the midpoints of the sides)

Definition at line 49 of file qgsregularpolygon.h.

Constructor & Destructor Documentation

◆ QgsRegularPolygon() [1/4]

QgsRegularPolygon::QgsRegularPolygon ( )
default

Constructor for QgsRegularPolygon.

◆ QgsRegularPolygon() [2/4]

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.

Parameters
centerThe center of the regular polygon.
radiusDistance from the center and the first vertex or sides (see ConstructionOption).
azimuthAngle in degrees started from the North to the first vertex.
numberSidesNumber of sides of the regular polygon.
circleOption to create the polygon.
See also
ConstructionOption

Definition at line 23 of file qgsregularpolygon.cpp.

◆ QgsRegularPolygon() [3/4]

QgsRegularPolygon::QgsRegularPolygon ( const QgsPoint center,
const QgsPoint pt1,
unsigned int  numberSides,
ConstructionOption  circle 
)

Constructs a regular polygon by center and another point.

Parameters
centerThe center of the regular polygon.
pt1The first vertex if the polygon is inscribed in circle or the midpoint of a side if the polygon is circumscribed about circle.
numberSidesNumber of sides of the regular polygon.
circleOption 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 52 of file qgsregularpolygon.cpp.

◆ QgsRegularPolygon() [4/4]

QgsRegularPolygon::QgsRegularPolygon ( const QgsPoint pt1,
const QgsPoint pt2,
unsigned int  numberSides 
)

Constructs a regular polygon by two points of the first side.

Parameters
pt1The first vertex of the first side, also first vertex of the regular polygon.
pt2The second vertex of the first side.
numberSidesNumber of sides of the regular polygon.

Definition at line 81 of file qgsregularpolygon.cpp.

Member Function Documentation

◆ apothem()

double QgsRegularPolygon::apothem ( ) const
inline

Returns the apothem of the regular polygon.

The apothem is the radius of the inscribed circle.

See also
radius()

Definition at line 118 of file qgsregularpolygon.h.

◆ area()

double QgsRegularPolygon::area ( ) const

Returns the area.

Returns 0 if the regular polygon is empty.

Definition at line 277 of file qgsregularpolygon.cpp.

◆ center()

QgsPoint QgsRegularPolygon::center ( ) const
inline

Returns the center point of the regular polygon.

See also
setCenter()

Definition at line 97 of file qgsregularpolygon.h.

◆ centralAngle()

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 327 of file qgsregularpolygon.cpp.

◆ circumscribedCircle()

QgsCircle QgsRegularPolygon::circumscribedCircle ( ) const

Returns the circumscribed circle.

Definition at line 254 of file qgsregularpolygon.cpp.

◆ firstVertex()

QgsPoint QgsRegularPolygon::firstVertex ( ) const
inline

Returns the first vertex (corner) of the regular polygon.

See also
setFirstVertex()

Definition at line 111 of file qgsregularpolygon.h.

◆ inscribedCircle()

QgsCircle QgsRegularPolygon::inscribedCircle ( ) const

Returns the inscribed circle.

Definition at line 248 of file qgsregularpolygon.cpp.

◆ interiorAngle()

double QgsRegularPolygon::interiorAngle ( ) const

Returns the measure of the interior angles in degrees.

Definition at line 322 of file qgsregularpolygon.cpp.

◆ isEmpty()

bool QgsRegularPolygon::isEmpty ( ) const

A regular polygon is empty if radius equal to 0 or number of sides < 3.

Definition at line 114 of file qgsregularpolygon.cpp.

◆ length()

double QgsRegularPolygon::length ( ) const

Returns the length of a side.

Returns 0 if the regular polygon is empty.

Definition at line 297 of file qgsregularpolygon.cpp.

◆ numberSides()

unsigned int QgsRegularPolygon::numberSides ( ) const
inline

Returns the number of sides of the regular polygon.

See also
setNumberSides()

Definition at line 124 of file qgsregularpolygon.h.

◆ operator!=()

bool QgsRegularPolygon::operator!= ( const QgsRegularPolygon rp) const

Definition at line 109 of file qgsregularpolygon.cpp.

◆ operator==()

bool QgsRegularPolygon::operator== ( const QgsRegularPolygon rp) const

Definition at line 101 of file qgsregularpolygon.cpp.

◆ perimeter()

double QgsRegularPolygon::perimeter ( ) const

Returns the perimeter.

Returns 0 if the regular polygon is empty.

Definition at line 287 of file qgsregularpolygon.cpp.

◆ points()

QgsPointSequence QgsRegularPolygon::points ( ) const

Returns a list including the vertices of the regular polygon.

Definition at line 155 of file qgsregularpolygon.cpp.

◆ radius()

double QgsRegularPolygon::radius ( ) const
inline

Returns the radius.

This is also the radius of the circumscribing circle.

See also
apothem()
setRadius()

Definition at line 105 of file qgsregularpolygon.h.

◆ setCenter()

void QgsRegularPolygon::setCenter ( const QgsPoint center)

Sets the center point.

Radius is unchanged. The first vertex is reprojected from the new center.

See also
center()

Definition at line 123 of file qgsregularpolygon.cpp.

◆ setFirstVertex()

void QgsRegularPolygon::setFirstVertex ( const QgsPoint firstVertex)

Sets the first vertex.

Radius is unchanged. The center is reprojected from the new first vertex.

See also
firstVertex()

Definition at line 139 of file qgsregularpolygon.cpp.

◆ setNumberSides()

void QgsRegularPolygon::setNumberSides ( unsigned int  numberSides)

Sets the number of sides.

If numberSides < 3, the number of sides is unchanged.

See also
numberSides()

Definition at line 147 of file qgsregularpolygon.cpp.

◆ setRadius()

void QgsRegularPolygon::setRadius ( double  radius)

Sets the radius.

Center is unchanged. The first vertex is reprojected from the center with the new radius.

See also
radius()

Definition at line 131 of file qgsregularpolygon.cpp.

◆ toLineString()

QgsLineString * QgsRegularPolygon::toLineString ( ) const

Returns as a linestring.

Definition at line 196 of file qgsregularpolygon.cpp.

◆ toPolygon()

QgsPolygon * QgsRegularPolygon::toPolygon ( ) const

Returns as a polygon.

Definition at line 183 of file qgsregularpolygon.cpp.

◆ toString()

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 260 of file qgsregularpolygon.cpp.

◆ toTriangle()

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 213 of file qgsregularpolygon.cpp.

◆ triangulate()

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 226 of file qgsregularpolygon.cpp.


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