QgsCircle class
Circle geometry type.
Contents
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).
Base classes
- class QgsEllipse
- Ellipse geometry type.
Public static functions
- static auto from2Points(const QgsPoint& pt1, const QgsPoint& pt2) -> QgsCircle
- Constructs a circle by 2 points on the circle.
- static auto from3Points(const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, double epsilon = 1E-8) -> QgsCircle
- Constructs a circle by 3 points on the circle.
- static auto 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) -> QgsCircle
- Constructs a circle by 3 tangents on the circle (aka inscribed circle of a triangle).
- static auto fromCenterDiameter(const QgsPoint& center, double diameter, double azimuth = 0) -> QgsCircle
- Constructs a circle by a center point and a diameter.
- static auto fromCenterPoint(const QgsPoint& center, const QgsPoint& pt1) -> QgsCircle
- Constructs a circle by a center point and another point.
- static auto fromExtent(const QgsPoint& pt1, const QgsPoint& pt2) -> QgsCircle
- Constructs a circle by an extent (aka bounding box / QgsRectangle).
- static auto minimalCircleFrom3Points(const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, double epsilon = 1E-8) -> QgsCircle
- Constructs the smallest circle from 3 points.
Constructors, destructors, conversion operators
Public functions
- auto area() const -> double override
- The area of the ellipse.
- auto boundingBox() const -> QgsRectangle override
- Returns the minimal bounding box for the ellipse.
- auto contains(const QgsPoint& point, double epsilon = 1E-8) const -> bool
- Returns true if the circle contains the point.
- auto innerTangents(const QgsCircle& other, QgsPointXY& line1P1, QgsPointXY& line1P2, QgsPointXY& line2P1, QgsPointXY& line2P2) const -> int
- Calculates the inner tangent points between this circle and an other circle.
- auto intersections(const QgsCircle& other, QgsPoint& intersection1, QgsPoint& intersection2, bool useZ = false) const -> int
- Calculates the intersections points between this circle and an other circle.
- auto northQuadrant() const -> QVector<QgsPoint>
- The four quadrants of the ellipse.
- auto outerTangents(const QgsCircle& other, QgsPointXY& line1P1, QgsPointXY& line1P2, QgsPointXY& line2P1, QgsPointXY& line2P2) const -> int
- Calculates the outer tangent points between this circle and an other circle.
- auto perimeter() const -> double override
- The circumference of the ellipse using first approximation of Ramanujan.
- auto radius() const -> double
- 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.
- auto tangentToPoint(const QgsPointXY& p, QgsPointXY& pt1, QgsPointXY& pt2) const -> bool
- Calculates the tangent points between this circle and the point p.
- auto toCircularString(bool oriented = false) const -> QgsCircularString*
- Returns a circular string from the circle.
- auto toString(int pointPrecision = 17, int axisPrecision = 17, int azimuthPrecision = 2) const -> QString override
- returns a string representation of the ellipse.
Function documentation
static QgsCircle QgsCircle:: from2Points(const QgsPoint& pt1,
const QgsPoint& pt2)
Constructs a circle by 2 points on the circle.
| Parameters | |
|---|---|
| pt1 | First point. |
| pt2 | Second point. |
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.
static QgsCircle QgsCircle:: from3Points(const QgsPoint& pt1,
const QgsPoint& pt2,
const QgsPoint& pt3,
double epsilon = 1E-8)
Constructs a circle by 3 points on the circle.
| Parameters | |
|---|---|
| pt1 | First point. |
| pt2 | Second point. |
| pt3 | Third point. |
| epsilon | Value used to compare point. |
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.
static QgsCircle 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)
Constructs a circle by 3 tangents on the circle (aka inscribed circle of a triangle).
| Parameters | |
|---|---|
| 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. |
Z and m values are dropped for the center point. The azimuth always takes the default value.
static QgsCircle QgsCircle:: fromCenterDiameter(const QgsPoint& center,
double diameter,
double azimuth = 0)
Constructs a circle by a center point and a diameter.
| Parameters | |
|---|---|
| center | Center point. |
| diameter | Diameter of the circle. |
| azimuth | Azimuth of the circle. |
The center point keeps z and m values from center.
static QgsCircle QgsCircle:: fromCenterPoint(const QgsPoint& center,
const QgsPoint& pt1)
Constructs a circle by a center point and another point.
| Parameters | |
|---|---|
| center | Center point. |
| pt1 | A point on the circle. |
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.
static QgsCircle QgsCircle:: fromExtent(const QgsPoint& pt1,
const QgsPoint& pt2)
Constructs a circle by an extent (aka bounding box / QgsRectangle).
| Parameters | |
|---|---|
| pt1 | First corner. |
| pt2 | Second corner. |
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.
static QgsCircle QgsCircle:: minimalCircleFrom3Points(const QgsPoint& pt1,
const QgsPoint& pt2,
const QgsPoint& pt3,
double epsilon = 1E-8)
Constructs the smallest circle from 3 points.
| Parameters | |
|---|---|
| pt1 | First point. |
| pt2 | Second point. |
| pt3 | Third point. |
| epsilon | Value used to compare point. |
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.
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).
Note that this method is 2D only and does not consider the z-value of the circle.
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.
| Returns | number of intersection points found. |
|---|
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.
QVector<QgsPoint> QgsCircle:: northQuadrant() const
The four quadrants of the ellipse.
| Returns | quadrants defined by four points. |
|---|
They are oriented and started from North.
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).
Note that this method is 2D only and does not consider the z-value of the circle.
void QgsCircle:: setSemiMajorAxis(double semiMajorAxis) override
Inherited method.
Use setRadius instead.
void QgsCircle:: setSemiMinorAxis(double semiMinorAxis) override
Inherited method.
Use setRadius instead.
bool QgsCircle:: tangentToPoint(const QgsPointXY& p,
QgsPointXY& pt1,
QgsPointXY& pt2) const
Calculates the tangent points between this circle and the point p.
| Returns | true if tangent was found. |
|---|
If found, the tangent points will be stored in pt1 and pt2.
Note that this method is 2D only and does not consider the z-value of the circle.
QgsCircularString* QgsCircle:: toCircularString(bool oriented = false) const
Returns a circular string from the circle.
| Parameters | |
|---|---|
| oriented | If oriented is true the start point is from azimuth instead from north. |
QString QgsCircle:: toString(int pointPrecision = 17,
int axisPrecision = 17,
int azimuthPrecision = 2) const override
returns a string representation of the ellipse.
Members will be truncated to the specified precision.