QGIS API Documentation  3.0.2-Girona (307d082)
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 "qgspoint.h"
26 #include "qgspolygon.h"
27 #include "qgsrectangle.h"
28 #include "qgscircularstring.h"
29 
30 
42 class CORE_EXPORT QgsCircle : public QgsEllipse
43 {
44  public:
45  QgsCircle();
46 
53  QgsCircle( const QgsPoint &center, double radius, double azimuth = 0 );
54 
65  static QgsCircle from2Points( const QgsPoint &pt1, const QgsPoint &pt2 );
66 
79  static QgsCircle from3Points( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon = 1E-8 );
80 
88  static QgsCircle fromCenterDiameter( const QgsPoint &center, double diameter, double azimuth = 0 );
89 
90 
99  static QgsCircle fromCenterPoint( const QgsPoint &center, const QgsPoint &pt1 );
100 
101 
114  static QgsCircle from3Tangents( const QgsPoint &pt1_tg1, const QgsPoint &pt2_tg1,
115  const QgsPoint &pt1_tg2, const QgsPoint &pt2_tg2,
116  const QgsPoint &pt1_tg3, const QgsPoint &pt2_tg3, double epsilon = 1E-8 );
117 
128  static QgsCircle fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 );
129 
140  static QgsCircle minimalCircleFrom3Points( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon = 1E-8 );
141 
142  double area() const override;
143  double perimeter() const override;
144 
145  //inherited
146  // void setAzimuth(const double azimuth);
147  // double azimuth() const {return mAzimuth; }
148 
149 
155  void setSemiMajorAxis( const double semiMajorAxis ) override;
156 
162  void setSemiMinorAxis( const double semiMinorAxis ) override;
163 
165  double radius() const {return mSemiMajorAxis;}
167  void setRadius( double radius )
168  {
169  mSemiMajorAxis = std::fabs( radius );
170  mSemiMinorAxis = mSemiMajorAxis;
171  }
172 
179  QVector<QgsPoint> northQuadrant() const SIP_FACTORY;
180 
185  QgsCircularString *toCircularString( bool oriented = false ) const;
186 
188  bool contains( const QgsPoint &point, double epsilon = 1E-8 ) const;
189 
190  QgsRectangle boundingBox() const override;
191 
192  QString toString( int pointPrecision = 17, int radiusPrecision = 17, int azimuthPrecision = 2 ) const override;
193 
194 };
195 
196 #endif // QGSCIRCLE_H
void setRadius(double radius)
Set the radius of the circle.
Definition: qgscircle.h:167
Circle geometry type.
Definition: qgscircle.h:42
A rectangle specified with double values.
Definition: qgsrectangle.h:39
static QgsEllipse fromCenterPoint(const QgsPoint &ptc, const QgsPoint &pt1)
Constructs an ellipse by a center point and a another point.
Definition: qgsellipse.cpp:77
virtual void setSemiMajorAxis(const double semiMajorAxis)
Sets the semi-major axis.
Definition: qgsellipse.cpp:124
double radius() const
Returns the radius of the circle.
Definition: qgscircle.h:165
double mSemiMajorAxis
Definition: qgsellipse.h:245
static QgsEllipse fromExtent(const QgsPoint &pt1, const QgsPoint &pt2)
Constructs an ellipse by an extent (aka bounding box / QgsRectangle).
Definition: qgsellipse.cpp:65
#define SIP_FACTORY
Definition: qgis_sip.h:69
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
virtual QString toString(int pointPrecision=17, int axisPrecision=17, int azimuthPrecision=2) const
returns a string representation of the ellipse.
Definition: qgsellipse.cpp:276
virtual double area() const
The area of the ellipse.
Definition: qgsellipse.cpp:165
Circular string geometry type.
Ellipse geometry type.
Definition: qgsellipse.h:39
virtual QgsRectangle boundingBox() const
Returns the minimal bounding box for the ellipse.
Definition: qgsellipse.cpp:253
virtual double perimeter() const
The circumference of the ellipse using first approximation of Ramanujan.
Definition: qgsellipse.cpp:170
virtual void setSemiMinorAxis(const double semiMinorAxis)
Sets the semi-minor axis.
Definition: qgsellipse.cpp:129