QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgscircle.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscircle.h
3  --------------
4  begin : March 2017
5  copyright : (C) 2017 by Loîc Bartoletti
6  email : lbartoletti at tuxfamily dot org
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 QGSCIRCLE_H
19 #define QGSCIRCLE_H
20 
21 #include <QString>
22 
23 #include "qgis_core.h"
24 #include "qgsellipse.h"
25 #include "qgspolygon.h"
26 #include "qgsrectangle.h"
27 #include "qgscircularstring.h"
28 
29 
30 class QgsPoint;
31 
43 class CORE_EXPORT QgsCircle : public QgsEllipse
44 {
45  public:
46  QgsCircle();
47 
54  QgsCircle( const QgsPoint &center, double radius, double azimuth = 0 ) SIP_HOLDGIL;
55 
66  static QgsCircle from2Points( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
67 
80  static QgsCircle from3Points( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon = 1E-8 ) SIP_HOLDGIL;
81 
89  static QgsCircle fromCenterDiameter( const QgsPoint &center, double diameter, double azimuth = 0 ) SIP_HOLDGIL;
90 
91 
100  static QgsCircle fromCenterPoint( const QgsPoint &center, const QgsPoint &pt1 ) SIP_HOLDGIL;
101 
102 
115  static QgsCircle from3Tangents( const QgsPoint &pt1_tg1, const QgsPoint &pt2_tg1,
116  const QgsPoint &pt1_tg2, const QgsPoint &pt2_tg2,
117  const QgsPoint &pt1_tg3, const QgsPoint &pt2_tg3, double epsilon = 1E-8 ) SIP_HOLDGIL;
118 
129  static QgsCircle fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
130 
141  static QgsCircle minimalCircleFrom3Points( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon = 1E-8 ) SIP_HOLDGIL;
142 
157  int intersections( const QgsCircle &other, QgsPoint &intersection1 SIP_OUT, QgsPoint &intersection2 SIP_OUT, bool useZ = false ) const;
158 
172  bool tangentToPoint( const QgsPointXY &p, QgsPointXY &pt1 SIP_OUT, QgsPointXY &pt2 SIP_OUT ) const;
173 
195  int outerTangents( const QgsCircle &other,
196  QgsPointXY &line1P1 SIP_OUT, QgsPointXY &line1P2 SIP_OUT,
197  QgsPointXY &line2P1 SIP_OUT, QgsPointXY &line2P2 SIP_OUT ) const;
198 
220  int innerTangents( const QgsCircle &other,
221  QgsPointXY &line1P1 SIP_OUT, QgsPointXY &line1P2 SIP_OUT,
222  QgsPointXY &line2P1 SIP_OUT, QgsPointXY &line2P2 SIP_OUT ) const;
223 
224  double area() const override SIP_HOLDGIL;
225  double perimeter() const override SIP_HOLDGIL;
226 
227  //inherited
228  // void setAzimuth(const double azimuth);
229  // double azimuth() const {return mAzimuth; }
230 
231 
237  void setSemiMajorAxis( double semiMajorAxis ) override SIP_HOLDGIL;
238 
244  void setSemiMinorAxis( double semiMinorAxis ) override SIP_HOLDGIL;
245 
247  double radius() const SIP_HOLDGIL {return mSemiMajorAxis;}
249  void setRadius( double radius ) SIP_HOLDGIL
250  {
251  mSemiMajorAxis = std::fabs( radius );
252  mSemiMinorAxis = mSemiMajorAxis;
253  }
254 
261  QVector<QgsPoint> northQuadrant() const SIP_FACTORY;
262 
267  QgsCircularString *toCircularString( bool oriented = false ) const;
268 
270  bool contains( const QgsPoint &point, double epsilon = 1E-8 ) const;
271 
272  QgsRectangle boundingBox() const override;
273 
274  QString toString( int pointPrecision = 17, int radiusPrecision = 17, int azimuthPrecision = 2 ) const override;
275 
276 #ifdef SIP_RUN
277  SIP_PYOBJECT __repr__();
278  % MethodCode
279  QString str = QStringLiteral( "<QgsCircle: %1>" ).arg( sipCpp->toString() );
280  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
281  % End
282 #endif
283 };
284 
285 #endif // QGSCIRCLE_H
qgspolygon.h
QgsCircle::setRadius
void setRadius(double radius) SIP_HOLDGIL
Sets the radius of the circle.
Definition: qgscircle.h:249
QgsEllipse
Ellipse geometry type.
Definition: qgsellipse.h:40
QgsEllipse::area
virtual double area() const SIP_HOLDGIL
The area of the ellipse.
Definition: qgsellipse.cpp:165
QgsEllipse::setSemiMinorAxis
virtual void setSemiMinorAxis(double semiMinorAxis) SIP_HOLDGIL
Sets the semi-minor axis.
Definition: qgsellipse.cpp:129
QgsEllipse::mSemiMajorAxis
double mSemiMajorAxis
Definition: qgsellipse.h:253
QgsCircle
Circle geometry type.
Definition: qgscircle.h:44
qgsrectangle.h
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_HOLDGIL
#define SIP_HOLDGIL
Definition: qgis_sip.h:157
QgsCircularString
Circular string geometry type.
Definition: qgscircularstring.h:35
QgsEllipse::fromExtent
static QgsEllipse fromExtent(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Constructs an ellipse by an extent (aka bounding box / QgsRectangle).
Definition: qgsellipse.cpp:65
qgsellipse.h
QgsCircle::radius
double radius() const SIP_HOLDGIL
Returns the radius of the circle.
Definition: qgscircle.h:247
qgscircularstring.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:44
QgsEllipse::fromCenterPoint
static QgsEllipse fromCenterPoint(const QgsPoint &ptc, const QgsPoint &pt1) SIP_HOLDGIL
Constructs an ellipse by a center point and a another point.
Definition: qgsellipse.cpp:77
QgsEllipse::perimeter
virtual double perimeter() const SIP_HOLDGIL
The circumference of the ellipse using first approximation of Ramanujan.
Definition: qgsellipse.cpp:170
QgsEllipse::setSemiMajorAxis
virtual void setSemiMajorAxis(double semiMajorAxis) SIP_HOLDGIL
Sets the semi-major axis.
Definition: qgsellipse.cpp:124