QGIS API Documentation
4.3.0-Master (9dce731a7a1)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
geometry
qgsregularpolygon.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsregularpolygon.h
3
--------------
4
begin : May 2017
5
copyright : (C) 2017 by Loïc Bartoletti
6
email : lituus at free dot fr
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#ifndef QGSREGULARPOLYGON_H
19
#define QGSREGULARPOLYGON_H
20
21
#include "qgis_core.h"
22
#include "
qgscircle.h
"
23
#include "
qgslinestring.h
"
24
#include "
qgspoint.h
"
25
#include "
qgspolygon.h
"
26
#include "
qgstriangle.h
"
27
28
#include <QString>
29
39
class
CORE_EXPORT
QgsRegularPolygon
40
{
41
public
:
46
enum
ConstructionOption
47
{
48
InscribedCircle
,
49
CircumscribedCircle
50
};
51
52
// clang-format off
56
QgsRegularPolygon
()
SIP_HOLDGIL
= default;
57
// clang-format on
58
67
QgsRegularPolygon
( const
QgsPoint
&
center
,
double
radius
,
double
azimuth,
unsigned
int
numberSides
,
ConstructionOption
circle )
SIP_HOLDGIL
;
68
76
QgsRegularPolygon
( const
QgsPoint
&
center
, const
QgsPoint
&pt1,
unsigned
int
numberSides
,
ConstructionOption
circle )
SIP_HOLDGIL
;
77
84
QgsRegularPolygon
( const
QgsPoint
&pt1, const
QgsPoint
&pt2,
unsigned
int
numberSides
)
SIP_HOLDGIL
;
85
86
bool
operator ==( const
QgsRegularPolygon
&rp ) const
SIP_HOLDGIL
;
87
bool
operator !=( const
QgsRegularPolygon
&rp ) const
SIP_HOLDGIL
;
88
90
bool
isEmpty
() const
SIP_HOLDGIL
;
91
96
QgsPoint
center
() const
SIP_HOLDGIL
{
return
mCenter; }
97
104
double
radius
() const
SIP_HOLDGIL
{
return
mRadius; }
105
110
QgsPoint
firstVertex
() const
SIP_HOLDGIL
{
return
mFirstVertex; }
111
117
double
apothem
() const
SIP_HOLDGIL
{
return
mRadius * std::cos( M_PI / mNumberSides ); }
118
123
unsigned
int
numberSides
() const
SIP_HOLDGIL
{
return
mNumberSides; }
124
130
void
setCenter(
const
QgsPoint
¢er )
SIP_HOLDGIL
;
131
137
void
setRadius(
double
radius )
SIP_HOLDGIL
;
138
144
void
setFirstVertex(
const
QgsPoint
&firstVertex )
SIP_HOLDGIL
;
145
151
void
setNumberSides(
unsigned
int
numberSides )
SIP_HOLDGIL
;
152
156
QgsPointSequence
points()
const
;
157
161
QgsPolygon
*toPolygon() const
SIP_FACTORY
;
162
166
QgsLineString
*toLineString() const
SIP_FACTORY
;
167
172
QgsTriangle
toTriangle() const;
173
178
QVector<
QgsTriangle
> triangulate() const;
179
183
QgsCircle
inscribedCircle() const
SIP_HOLDGIL
;
184
188
QgsCircle
circumscribedCircle() const
SIP_HOLDGIL
;
189
194
QString toString(
int
pointPrecision = 17,
int
radiusPrecision = 17,
int
anglePrecision = 2 ) const;
195
199
double
interiorAngle() const
SIP_HOLDGIL
;
200
204
double
centralAngle() const
SIP_HOLDGIL
;
205
210
double
area() const
SIP_HOLDGIL
;
211
216
double
perimeter() const
SIP_HOLDGIL
;
217
222
double
length() const
SIP_HOLDGIL
;
223
224
private:
225
QgsPoint
mCenter;
226
QgsPoint
mFirstVertex;
227
unsigned
int
mNumberSides = 0;
228
double
mRadius = 0.0;
229
233
double
apothemToRadius(
double
apothem,
unsigned
int
numberSides ) const;
234
238
double
interiorAngle(
unsigned
int
nbSides ) const;
239
243
double
centralAngle(
unsigned
int
nbSides ) const;
244
245
};
246
247
#endif
// QGSREGULARPOLYGON_H
QgsCircle
Circle geometry type.
Definition
qgscircle.h:46
QgsLineString
Line string geometry type, with support for z-dimension and m-values.
Definition
qgslinestring.h:49
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition
qgspoint.h:53
QgsPolygon
Polygon geometry type.
Definition
qgspolygon.h:37
QgsRegularPolygon::QgsRegularPolygon
QgsRegularPolygon()=default
Constructor for QgsRegularPolygon.
QgsRegularPolygon::center
QgsPoint center() const
Returns the center point of the regular polygon.
Definition
qgsregularpolygon.h:96
QgsRegularPolygon::firstVertex
QgsPoint firstVertex() const
Returns the first vertex (corner) of the regular polygon.
Definition
qgsregularpolygon.h:110
QgsRegularPolygon::ConstructionOption
ConstructionOption
A regular polygon can be constructed inscribed in a circle or circumscribed about a circle.
Definition
qgsregularpolygon.h:47
QgsRegularPolygon::CircumscribedCircle
@ CircumscribedCircle
Circumscribed about a circle (the radius is the distance from the center to the midpoints of the side...
Definition
qgsregularpolygon.h:49
QgsRegularPolygon::InscribedCircle
@ InscribedCircle
Inscribed in a circle (the radius is the distance between the center and vertices).
Definition
qgsregularpolygon.h:48
QgsRegularPolygon::radius
double radius() const
Returns the radius.
Definition
qgsregularpolygon.h:104
QgsRegularPolygon::numberSides
unsigned int numberSides() const
Returns the number of sides of the regular polygon.
Definition
qgsregularpolygon.h:123
QgsRegularPolygon::isEmpty
bool isEmpty() const
A regular polygon is empty if radius equal to 0 or number of sides < 3.
Definition
qgsregularpolygon.cpp:112
QgsRegularPolygon::apothem
double apothem() const
Returns the apothem of the regular polygon.
Definition
qgsregularpolygon.h:117
QgsTriangle
Triangle geometry type.
Definition
qgstriangle.h:33
SIP_HOLDGIL
#define SIP_HOLDGIL
Definition
qgis_sip.h:183
SIP_FACTORY
#define SIP_FACTORY
Definition
qgis_sip.h:83
QgsPointSequence
QVector< QgsPoint > QgsPointSequence
Definition
qgsabstractgeometry.h:57
qgscircle.h
qgslinestring.h
qgspoint.h
qgspolygon.h
qgstriangle.h
Generated on
for QGIS API Documentation by
1.17.0