QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
52 double yDelta_a = pt2.
y() - pt1.
y();
53 double xDelta_a = pt2.
x() - pt1.
x();
54 double yDelta_b = pt3.
y() - pt2.
y();
55 double xDelta_b = pt3.
x() - pt2.
x();
57 if ( ( std::fabs( xDelta_a ) <= epsilon ) && ( std::fabs( yDelta_b ) <= epsilon ) )
62 if ( std::fabs( yDelta_a ) <= epsilon )
66 else if ( std::fabs( yDelta_b ) <= epsilon )
70 else if ( std::fabs( xDelta_a ) <= epsilon )
74 else if ( std::fabs( xDelta_b ) <= epsilon )
87 if ( !isPerpendicular( pt1, pt2, pt3, epsilon ) )
93 else if ( !isPerpendicular( pt1, pt3, pt2, epsilon ) )
99 else if ( !isPerpendicular( pt2, pt1, pt3, epsilon ) )
105 else if ( !isPerpendicular( pt2, pt3, pt1, epsilon ) )
111 else if ( !isPerpendicular( pt3, pt2, pt1, epsilon ) )
117 else if ( !isPerpendicular( pt3, pt1, pt2, epsilon ) )
130 double yDelta_a = p2.
y() - p1.
y();
131 double xDelta_a = p2.
x() - p1.
x();
132 double yDelta_b = p3.
y() - p2.
y();
133 double xDelta_b = p3.
x() - p2.
x();
140 double aSlope = yDelta_a / xDelta_a;
141 double bSlope = yDelta_b / xDelta_b;
146 if ( ( std::fabs( xDelta_a ) <= epsilon ) && ( std::fabs( yDelta_b ) <= epsilon ) )
155 if ( std::fabs( aSlope - bSlope ) <= epsilon )
161 ( aSlope * bSlope * ( p1.
y() - p3.
y() ) +
162 bSlope * ( p1.
x() + p2.
x() ) -
163 aSlope * ( p2.
x() + p3.
x() ) ) /
164 ( 2.0 * ( bSlope - aSlope ) )
167 -1.0 * (
center.
x() - ( p1.
x() + p2.
x() ) / 2.0 ) /
168 aSlope + ( p1.
y() + p2.
y() ) / 2.0
194 bool isIntersect =
false;
229 if ( ( l1 * l1 ) - ( l2 * l2 + l3 * l3 ) >= epsilon )
230 return QgsCircle().from2Points( pt2, pt3 );
231 else if ( ( l2 * l2 ) - ( l1 * l1 + l3 * l3 ) >= epsilon )
232 return QgsCircle().from2Points( pt3, pt1 );
233 else if ( ( l3 * l3 ) - ( l1 * l1 + l2 * l2 ) >= epsilon )
234 return QgsCircle().from2Points( pt1, pt2 );
236 return QgsCircle().from3Points( pt1, pt2, pt3, epsilon );
281 double delta_x = std::fabs( pt1.
x() - pt2.
x() );
282 double delta_y = std::fabs( pt1.
x() - pt2.
y() );
318 QVector<QgsPoint> quad;
331 QVector<QgsPoint> quad;
340 quad.append( quad.at( 0 ) );
341 for ( QVector<QgsPoint>::const_iterator it = quad.constBegin(); it != quad.constEnd(); ++it )
345 circString->setPoints(
points );
347 return circString.release();
364 rep = QStringLiteral(
"Empty" );
366 rep = QStringLiteral(
"Circle (Center: %1, Radius: %2, Azimuth: %3)" )
bool contains(const QgsPoint &point, double epsilon=1E-8) const
Returns true if the circle contains the point.
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.
QString toString(int pointPrecision=17, int radiusPrecision=17, int azimuthPrecision=2) const override
returns a string representation of the ellipse.
double semiMajorAxis() const SIP_HOLDGIL
Returns the semi-major axis.
void setSemiMajorAxis(double semiMajorAxis) override SIP_HOLDGIL
Inherited method.
static QgsCircle minimalCircleFrom3Points(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon=1E-8) SIP_HOLDGIL
Constructs the smallest circle from 3 points.
double distance(double x, double y) const SIP_HOLDGIL
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
Point geometry type, with support for z-dimension and m-values.
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.
QString asWkt(int precision=17) const override
Returns a WKT representation of the geometry.
bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
QgsRectangle boundingBox() const override
Returns the minimal bounding box for the ellipse.
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) SIP_HOLDGIL
Constructs a circle by 3 tangents on the circle (aka inscribed circle of a triangle).
double area() const override SIP_HOLDGIL
The area of the ellipse.
static double lineAngle(double x1, double y1, double x2, double y2) SIP_HOLDGIL
Calculates the direction of line joining two points in radians, clockwise from the north direction.
static int circleCircleOuterTangents(const QgsPointXY ¢er1, double radius1, const QgsPointXY ¢er2, double radius2, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2) SIP_HOLDGIL
Calculates the outer tangent points for two circles, centered at center1 and center2 and with radii o...
virtual QVector< QgsPoint > quadrant() const
The four quadrants of the ellipse.
virtual bool isEmpty() const SIP_HOLDGIL
An ellipse is empty if axes are equal to 0.
virtual QgsPointSequence points(unsigned int segments=36) const
Returns a list of points with segmentation from segments.
QgsCircle inscribedCircle() const SIP_HOLDGIL
Inscribed circle of the triangle.
static QgsCircle from3Points(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon=1E-8) SIP_HOLDGIL
Constructs a circle by 3 points on the circle.
A rectangle specified with double values.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
static QgsCircle from2Points(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Constructs a circle by 2 points on the circle.
QVector< QgsPoint > northQuadrant() const
The four quadrants of the ellipse.
int intersections(const QgsCircle &other, QgsPoint &intersection1, QgsPoint &intersection2, bool useZ=false) const
Calculates the intersections points between this circle and an other circle.
Circular string geometry type.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
double semiMinorAxis() const SIP_HOLDGIL
Returns the semi-minor axis.
static int circleCircleIntersections(QgsPointXY center1, double radius1, QgsPointXY center2, double radius2, QgsPointXY &intersection1, QgsPointXY &intersection2) SIP_HOLDGIL
Calculates the intersections points between the circle with center center1 and radius radius1 and the...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
double azimuth() const SIP_HOLDGIL
Returns the azimuth.
double radius() const SIP_HOLDGIL
Returns the radius of the circle.
static QgsCircle fromCenterDiameter(const QgsPoint ¢er, double diameter, double azimuth=0) SIP_HOLDGIL
Constructs a circle by a center point and a diameter.
void setX(double x) SIP_HOLDGIL
Sets the point's x-coordinate.
QgsCircularString * toCircularString(bool oriented=false) const
Returns a circular string from the circle.
static Type dropZ(Type type) SIP_HOLDGIL
Drops the z dimension (if present) for a WKB type and returns the new type.
static bool segmentIntersection(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance=1e-8, bool acceptImproperIntersection=false) SIP_HOLDGIL
Compute the intersection between two segments.
QgsPoint center() const SIP_HOLDGIL
Returns the center point.
bool tangentToPoint(const QgsPointXY &p, QgsPointXY &pt1, QgsPointXY &pt2) const
Calculates the tangent points between this circle and the point p.
void setSemiMinorAxis(double semiMinorAxis) override SIP_HOLDGIL
Inherited method.
double perimeter() const override SIP_HOLDGIL
The circumference of the ellipse using first approximation of Ramanujan.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
A class to represent a 2D point.
static QgsPoint midpoint(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Returns a middle point between points pt1 and pt2.
QVector< QgsPoint > QgsPointSequence
static int circleCircleInnerTangents(const QgsPointXY ¢er1, double radius1, const QgsPointXY ¢er2, double radius2, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2) SIP_HOLDGIL
Calculates the inner tangent points for two circles, centered at center1 and center2 and with radii o...
static QgsCircle fromCenterPoint(const QgsPoint ¢er, const QgsPoint &pt1) SIP_HOLDGIL
Constructs a circle by a center point and another point.
bool convertTo(QgsWkbTypes::Type type) override
Converts the geometry to a specified type.
void setY(double y) SIP_HOLDGIL
Sets the point's y-coordinate.
static bool setZValueFromPoints(const QgsPointSequence &points, QgsPoint &point)
A Z dimension is added to point if one of the point in the list points is in 3D.
static QgsCircle fromExtent(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Constructs a circle by an extent (aka bounding box / QgsRectangle).
static bool tangentPointAndCircle(const QgsPointXY ¢er, double radius, const QgsPointXY &p, QgsPointXY &pt1, QgsPointXY &pt2) SIP_HOLDGIL
Calculates the tangent points between the circle with the specified center and radius and the point p...