QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
Circle geometry type. More...
#include <qgscircle.h>
Public Member Functions | |
QgsCircle () | |
QgsCircle (const QgsPoint ¢er, double radius, double azimuth=0) | |
Constructs a circle by defining all the members. | |
double | area () const override |
The area of the ellipse. | |
QDomElement | asGml2 (QDomDocument &doc, int precision=17, const QString &ns="gml", QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const |
Returns a GML2 representation of the geometry. | |
QDomElement | asGml3 (QDomDocument &doc, int precision=17, const QString &ns="gml", QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const |
Returns a GML3 representation of the geometry. | |
QgsRectangle | boundingBox () const override |
Returns the minimal bounding box for the ellipse. | |
bool | contains (const QgsPoint &point, double epsilon=1E-8) const |
Returns true if the circle contains the point. | |
int | innerTangents (const QgsCircle &other, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2) const |
Calculates the inner tangent points between this circle and an other circle. | |
int | intersections (const QgsCircle &other, QgsPoint &intersection1, QgsPoint &intersection2, bool useZ=false) const |
Calculates the intersections points between this circle and an other circle. | |
QVector< QgsPoint > | northQuadrant () const |
The four quadrants of the ellipse. | |
int | outerTangents (const QgsCircle &other, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2) const |
Calculates the outer tangent points between this circle and an other circle. | |
double | perimeter () const override |
The circumference of the ellipse using first approximation of Ramanujan. | |
double | radius () const |
Returns the radius of the circle. | |
void | setRadius (double radius) |
Sets the radius of the circle. | |
void | setSemiMajorAxis (double semiMajorAxis) override |
Inherited method. | |
void | setSemiMinorAxis (double semiMinorAxis) override |
Inherited method. | |
bool | tangentToPoint (const QgsPointXY &p, QgsPointXY &pt1, QgsPointXY &pt2) const |
Calculates the tangent points between this circle and the point p. | |
QgsCircularString * | toCircularString (bool oriented=false) const |
Returns a circular string from the circle. | |
QString | toString (int pointPrecision=17, int radiusPrecision=17, int azimuthPrecision=2) const override |
returns a string representation of the ellipse. | |
Public Member Functions inherited from QgsEllipse | |
QgsEllipse ()=default | |
Constructor for QgsEllipse. | |
QgsEllipse (const QgsPoint ¢er, double semiMajorAxis, double semiMinorAxis, double azimuth=90) | |
Constructs an ellipse by defining all the members. | |
virtual | ~QgsEllipse ()=default |
double | azimuth () const |
Returns the azimuth. | |
QgsPoint | center () const |
Returns the center point. | |
virtual double | eccentricity () const |
The eccentricity of the ellipse. | |
virtual QVector< QgsPoint > | foci () const |
Two foci of the ellipse. | |
virtual double | focusDistance () const |
The distance between the center and each foci. | |
virtual bool | isEmpty () const |
An ellipse is empty if axes are equal to 0. | |
virtual bool | operator!= (const QgsEllipse &elp) const |
virtual bool | operator== (const QgsEllipse &elp) const |
virtual QgsPolygon * | orientedBoundingBox () const |
Returns the oriented minimal bounding box for the ellipse. | |
virtual QgsPointSequence | points (unsigned int segments=36) const |
Returns a list of points with segmentation from segments. | |
virtual QVector< QgsPoint > | quadrant () const |
The four quadrants of the ellipse. | |
QgsPoint & | rcenter () |
Returns a reference to the center point of this ellipse. | |
double | semiMajorAxis () const |
Returns the semi-major axis. | |
double | semiMinorAxis () const |
Returns the semi-minor axis. | |
void | setAzimuth (double azimuth) |
Sets the azimuth (orientation). | |
void | setCenter (const QgsPoint ¢er) |
Sets the center point. | |
virtual QgsLineString * | toLineString (unsigned int segments=36) const |
Returns a segmented linestring. | |
virtual QgsPolygon * | toPolygon (unsigned int segments=36) const |
Returns a segmented polygon. | |
Static Public Member Functions | |
static QgsCircle | from2Points (const QgsPoint &pt1, const QgsPoint &pt2) |
Constructs a circle by 2 points on the circle. | |
static QgsCircle | from3Points (const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon=1E-8) |
Constructs a circle by 3 points on the circle. | |
static QgsCircle | from3Tangents (const QgsPoint &pt1_tg1, const QgsPoint &pt2_tg1, const QgsPoint &pt1_tg2, const QgsPoint &pt2_tg2, const QgsPoint &pt1_tg3, const QgsPoint &pt2_tg3, double epsilon=1E-8, const QgsPoint &pos=QgsPoint()) |
Constructs a circle by 3 tangents on the circle (aka inscribed circle of a triangle). | |
static QVector< QgsCircle > | from3TangentsMulti (const QgsPoint &pt1_tg1, const QgsPoint &pt2_tg1, const QgsPoint &pt1_tg2, const QgsPoint &pt2_tg2, const QgsPoint &pt1_tg3, const QgsPoint &pt2_tg3, double epsilon=1E-8, const QgsPoint &pos=QgsPoint()) |
Returns an array of circle constructed by 3 tangents on the circle (aka inscribed circle of a triangle). | |
static QgsCircle | fromCenterDiameter (const QgsPoint ¢er, double diameter, double azimuth=0) |
Constructs a circle by a center point and a diameter. | |
static QgsCircle | fromCenterPoint (const QgsPoint ¢er, const QgsPoint &pt1) |
Constructs a circle by a center point and another point. | |
static QgsCircle | fromExtent (const QgsPoint &pt1, const QgsPoint &pt2) |
Constructs a circle by an extent (aka bounding box / QgsRectangle). | |
static QgsCircle | minimalCircleFrom3Points (const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon=1E-8) |
Constructs the smallest circle from 3 points. | |
Static Public Member Functions inherited from QgsEllipse | |
static QgsEllipse | fromCenter2Points (const QgsPoint &ptc, const QgsPoint &pt1, const QgsPoint &pt2) |
Constructs an ellipse by a central point and two other points. | |
static QgsEllipse | fromCenterPoint (const QgsPoint &ptc, const QgsPoint &pt1) |
Constructs an ellipse by a center point and a another point. | |
static QgsEllipse | fromExtent (const QgsPoint &pt1, const QgsPoint &pt2) |
Constructs an ellipse by an extent (aka bounding box / QgsRectangle). | |
static QgsEllipse | fromFoci (const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3) |
Constructs an ellipse by foci (pt1 and pt2) and a point pt3. | |
Additional Inherited Members | |
Protected Attributes inherited from QgsEllipse | |
double | mAzimuth = 90.0 |
QgsPoint | mCenter |
double | mSemiMajorAxis = 0.0 |
double | mSemiMinorAxis = 0.0 |
Circle geometry type.
A circle is defined by a center point with a radius and an azimuth. The azimuth is the north angle to the semi-major axis, in degrees. By default, the semi-major axis is oriented to the north (0 degrees).
Definition at line 42 of file qgscircle.h.
QgsCircle::QgsCircle | ( | ) |
Definition at line 26 of file qgscircle.cpp.
QgsCircle::QgsCircle | ( | const QgsPoint & | center, |
double | radius, | ||
double | azimuth = 0 |
||
) |
Constructs a circle by defining all the members.
center | The center of the circle. |
radius | The radius of the circle. |
azimuth | Angle in degrees started from the North to the first quadrant. |
Definition at line 32 of file qgscircle.cpp.
|
overridevirtual |
The area of the ellipse.
Reimplemented from QgsEllipse.
Definition at line 397 of file qgscircle.cpp.
QDomElement QgsCircle::asGml2 | ( | QDomDocument & | doc, |
int | precision = 17 , |
||
const QString & | ns = "gml" , |
||
QgsAbstractGeometry::AxisOrder | axisOrder = QgsAbstractGeometry::AxisOrder::XY |
||
) | const |
Returns a GML2 representation of the geometry.
Since GML2 does not supports curve, it will be converted to a LineString.
doc | DOM document |
precision | number of decimal places for coordinates |
ns | XML namespace |
axisOrder | Axis order for generated GML |
Definition at line 478 of file qgscircle.cpp.
QDomElement QgsCircle::asGml3 | ( | QDomDocument & | doc, |
int | precision = 17 , |
||
const QString & | ns = "gml" , |
||
QgsAbstractGeometry::AxisOrder | axisOrder = QgsAbstractGeometry::AxisOrder::XY |
||
) | const |
Returns a GML3 representation of the geometry.
From the GML3 description: A Circle is an arc whose ends coincide to form a simple closed loop. The three control points shall be distinct non-co-linear points for the circle to be unambiguously defined. The arc is simply extended past the third control point until the first control point is encountered.
Coordinates are taken from quadrant North, East and South.
doc | DOM document |
precision | number of decimal places for coordinates |
ns | XML namespace |
axisOrder | Axis order for generated GML |
Definition at line 486 of file qgscircle.cpp.
|
overridevirtual |
Returns the minimal bounding box for the ellipse.
Reimplemented from QgsEllipse.
Definition at line 458 of file qgscircle.cpp.
bool QgsCircle::contains | ( | const QgsPoint & | point, |
double | epsilon = 1E-8 |
||
) | const |
Returns true
if the circle contains the point.
Definition at line 453 of file qgscircle.cpp.
Constructs a circle by 2 points on the circle.
The center point can have m value which is the result from the midpoint operation between pt1 and pt2. Z dimension is also supported and is retrieved from the first 3D point amongst pt1 and pt2. The radius is calculated from the 2D distance between pt1 and pt2. The azimuth is the angle between pt1 and pt2.
pt1 | First point. |
pt2 | Second point. |
Definition at line 38 of file qgscircle.cpp.
|
static |
Constructs a circle by 3 points on the circle.
M value is dropped for the center point. Z dimension is supported and is retrieved from the first 3D point amongst pt1, pt2 and pt3. The azimuth always takes the default value. If the points are colinear an empty circle is returned.
pt1 | First point. |
pt2 | Second point. |
pt3 | Third point. |
epsilon | Value used to compare point. |
Definition at line 84 of file qgscircle.cpp.
|
static |
Constructs a circle by 3 tangents on the circle (aka inscribed circle of a triangle).
Z and m values are dropped for the center point. The azimuth always takes the default value.
pt1_tg1 | First point of the first tangent. |
pt2_tg1 | Second point of the first tangent. |
pt1_tg2 | First point of the second tangent. |
pt2_tg2 | Second point of the second tangent. |
pt1_tg3 | First point of the third tangent. |
pt2_tg3 | Second point of the third tangent. |
epsilon | Value used to compare point. |
pos | Point to determine which circle use in case of multi return. If the solution is not unique and pos is an empty point, an empty circle is returned. – This case happens only when two tangents are parallels. (since QGIS 3.18) |
Definition at line 318 of file qgscircle.cpp.
|
static |
Returns an array of circle constructed by 3 tangents on the circle (aka inscribed circle of a triangle).
The vector can contain 0, 1 or 2 circles:
Z and m values are dropped for the center point. The azimuth always takes the default value.
pt1_tg1 | First point of the first tangent. |
pt2_tg1 | Second point of the first tangent. |
pt1_tg2 | First point of the second tangent. |
pt2_tg2 | Second point of the second tangent. |
pt1_tg3 | First point of the third tangent. |
pt2_tg3 | Second point of the third tangent. |
epsilon | Value used to compare point. |
pos | (optional) Point to determine which circle use in case of multi return. |
Definition at line 278 of file qgscircle.cpp.
|
static |
Constructs a circle by a center point and a diameter.
The center point keeps z and m values from center.
center | Center point. |
diameter | Diameter of the circle. |
azimuth | Azimuth of the circle. |
Definition at line 177 of file qgscircle.cpp.
Constructs a circle by a center point and another point.
The center point keeps z and m values from center. Axes are calculated from the 2D distance between center and pt1. The azimuth is the angle between center and pt1.
center | Center point. |
pt1 | A point on the circle. |
Definition at line 182 of file qgscircle.cpp.
Constructs a circle by an extent (aka bounding box / QgsRectangle).
The center point can have m value which is the result from the midpoint operation between pt1 and pt2. Z dimension is also supported and is retrieved from the first 3D point amongst pt1 and pt2. Axes are calculated from the 2D distance between pt1 and pt2. The azimuth always takes the default value.
pt1 | First corner. |
pt2 | Second corner. |
Definition at line 382 of file qgscircle.cpp.
int QgsCircle::innerTangents | ( | const QgsCircle & | other, |
QgsPointXY & | line1P1, | ||
QgsPointXY & | line1P2, | ||
QgsPointXY & | line2P1, | ||
QgsPointXY & | line2P2 | ||
) | const |
Calculates the inner tangent points between this circle and an other circle.
The inner tangent points correspond to the points at which the two lines which are drawn so that they are tangential to both circles but on different sides, touching the circles and crossing each other.
The first tangent line is described by the points stored in line1P1 and line1P2, and the second line is described by the points stored in line2P1 and line2P2.
Returns the number of tangents (either 0 or 2).
Definition at line 376 of file qgscircle.cpp.
int QgsCircle::intersections | ( | const QgsCircle & | other, |
QgsPoint & | intersection1, | ||
QgsPoint & | intersection2, | ||
bool | useZ = false |
||
) | const |
Calculates the intersections points between this circle and an other circle.
If found, the intersection points will be stored in intersection1 and intersection2.
By default this method does not consider any z values and instead treats the circles as 2-dimensional. If useZ is set to true
, then an intersection will only occur if the z values of both circles are equal. In this case the points returned for intersection1 and intersection2 will contain the z value of the circle intersections.
Definition at line 342 of file qgscircle.cpp.
|
static |
Constructs the smallest circle from 3 points.
Z and m values are dropped for the center point. The azimuth always takes the default value. If the points are colinear an empty circle is returned.
pt1 | First point. |
pt2 | Second point. |
pt3 | Third point. |
epsilon | Value used to compare point. |
Definition at line 326 of file qgscircle.cpp.
QVector< QgsPoint > QgsCircle::northQuadrant | ( | ) | const |
The four quadrants of the ellipse.
They are oriented and started from North.
Definition at line 419 of file qgscircle.cpp.
int QgsCircle::outerTangents | ( | const QgsCircle & | other, |
QgsPointXY & | line1P1, | ||
QgsPointXY & | line1P2, | ||
QgsPointXY & | line2P1, | ||
QgsPointXY & | line2P2 | ||
) | const |
Calculates the outer tangent points between this circle and an other circle.
The outer tangent points correspond to the points at which the two lines which are drawn so that they are tangential to both circles touch the circles.
The first tangent line is described by the points stored in line1P1 and line1P2, and the second line is described by the points stored in line2P1 and line2P2.
Returns the number of tangents (either 0 or 2).
Definition at line 370 of file qgscircle.cpp.
|
overridevirtual |
The circumference of the ellipse using first approximation of Ramanujan.
Reimplemented from QgsEllipse.
Definition at line 402 of file qgscircle.cpp.
|
inline |
Returns the radius of the circle.
Definition at line 310 of file qgscircle.h.
|
inline |
Sets the radius of the circle.
Definition at line 312 of file qgscircle.h.
|
overridevirtual |
Inherited method.
Use setRadius instead.
Reimplemented from QgsEllipse.
Definition at line 407 of file qgscircle.cpp.
|
overridevirtual |
Inherited method.
Use setRadius instead.
Reimplemented from QgsEllipse.
Definition at line 413 of file qgscircle.cpp.
bool QgsCircle::tangentToPoint | ( | const QgsPointXY & | p, |
QgsPointXY & | pt1, | ||
QgsPointXY & | pt2 | ||
) | const |
Calculates the tangent points between this circle and the point p.
If found, the tangent points will be stored in pt1 and pt2.
true
if tangent was found.Definition at line 365 of file qgscircle.cpp.
QgsCircularString * QgsCircle::toCircularString | ( | bool | oriented = false | ) | const |
Returns a circular string from the circle.
oriented | If oriented is true the start point is from azimuth instead from north. |
Definition at line 430 of file qgscircle.cpp.
|
overridevirtual |
returns a string representation of the ellipse.
Members will be truncated to the specified precision.
Reimplemented from QgsEllipse.
Definition at line 463 of file qgscircle.cpp.