QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
26 void QgsEllipse::normalizeAxis()
40 , mSemiMajorAxis( axis_a )
41 , mSemiMinorAxis( axis_b )
49 double dist_p1p2 = pt1.
distance( pt2 );
50 double dist_p1p3 = pt1.
distance( pt3 );
51 double dist_p2p3 = pt2.
distance( pt3 );
53 double dist = dist_p1p3 + dist_p2p3;
57 double axis_a = dist / 2.0;
58 double axis_b = std::sqrt( std::pow( axis_a, 2.0 ) - std::pow( dist_p1p2 / 2.0, 2.0 ) );
68 double axis_a = std::fabs( pt2.
x() - pt1.
x() ) / 2.0;
69 double axis_b = std::fabs( pt2.
y() - pt1.
y() ) / 2.0;
79 double axis_a = std::fabs( pt1.
x() -
center.
x() );
80 double axis_b = std::fabs( pt1.
y() -
center.
y() );
160 return std::numeric_limits<double>::quiet_NaN();
174 return M_PI * ( 3 * ( a + b ) - std::sqrt( 10 * a * b + 3 * ( a * a + b * b ) ) );
179 QVector<QgsPoint> quad;
203 t.reserve( segments );
205 for (
unsigned int i = 0; i < segments; ++i )
207 t.append( 2 * M_PI - ( ( 2 * M_PI ) / segments * i ) );
210 for ( QVector<double>::const_iterator it = t.constBegin(); it != t.constEnd(); ++it )
218 pts.push_back(
QgsPoint( pType, x, y, z, m ) );
226 std::unique_ptr<QgsPolygon> polygon(
new QgsPolygon() );
229 return polygon.release();
234 return polygon.release();
242 return ext.release();
247 pts.append( pts.at( 0 ) );
249 ext->setPoints( pts );
251 return ext.release();
268 double halfHeight = std::sqrt( ux * ux + uy * uy );
269 double halfWidth = std::sqrt( vx * vx + vy * vy );
281 rep = QStringLiteral(
"Empty" );
283 rep = QStringLiteral(
"Ellipse (Center: %1, Semi-Major Axis: %2, Semi-Minor Axis: %3, Azimuth: %4)" )
294 std::unique_ptr<QgsPolygon> ombb(
new QgsPolygon() );
297 return ombb.release();
310 ombb->setExteriorRing( ext );
312 return ombb.release();
virtual double area() const SIP_HOLDGIL
The area of the ellipse.
virtual void setSemiMinorAxis(double semiMinorAxis) SIP_HOLDGIL
Sets the semi-minor axis.
void setPoints(const QgsPointSequence &points)
Resets the line string to match the specified list of 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.
QString asWkt(int precision=17) const override
Returns a WKT representation of the geometry.
virtual QVector< QgsPoint > foci() const
Two foci of the ellipse.
static QgsPoint projectPointOnSegment(const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2) SIP_HOLDGIL
Project the point on a segment.
static QgsEllipse fromFoci(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3) SIP_HOLDGIL
Constructs an ellipse by foci (pt1 and pt2) and a point pt3.
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.
virtual double focusDistance() const SIP_HOLDGIL
The distance between the center and each foci.
Type
The WKB type describes the number of dimensions a geometry has.
virtual QVector< QgsPoint > quadrant() const
The four quadrants of the ellipse.
Line string geometry type, with support for z-dimension and m-values.
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.
virtual QgsLineString * toLineString(unsigned int segments=36) const
Returns a segmented linestring.
A rectangle specified with double values.
QgsPoint project(double distance, double azimuth, double inclination=90.0) const SIP_HOLDGIL
Returns a new point which correspond to this point projected by a specified distance with specified a...
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
static double normalizedAngle(double angle) SIP_HOLDGIL
Ensures that an angle is in the range 0 <= angle < 2 pi.
QgsEllipse() SIP_HOLDGIL=default
Constructor for QgsEllipse.
static QgsEllipse fromExtent(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Constructs an ellipse by an extent (aka bounding box / QgsRectangle).
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
virtual QString toString(int pointPrecision=17, int axisPrecision=17, int azimuthPrecision=2) const
returns a string representation of the ellipse.
virtual QgsRectangle boundingBox() const
Returns the minimal bounding box for the ellipse.
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.
void setAzimuth(double azimuth) SIP_HOLDGIL
Sets the azimuth (orientation).
QgsPoint center() const SIP_HOLDGIL
Returns the center point.
static QgsEllipse fromCenter2Points(const QgsPoint &ptc, const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Constructs an ellipse by a central point and two other points.
A class to represent a 2D point.
virtual bool operator!=(const QgsEllipse &elp) const
static QgsPoint midpoint(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Returns a middle point between points pt1 and pt2.
virtual double eccentricity() const SIP_HOLDGIL
The eccentricity of the ellipse.
QVector< QgsPoint > QgsPointSequence
virtual QgsPolygon * orientedBoundingBox() const
Returns the oriented minimal bounding box for the ellipse.
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
static QgsEllipse fromCenterPoint(const QgsPoint &ptc, const QgsPoint &pt1) SIP_HOLDGIL
Constructs an ellipse by a center point and a another point.
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.
virtual double perimeter() const SIP_HOLDGIL
The circumference of the ellipse using first approximation of Ramanujan.
virtual void setSemiMajorAxis(double semiMajorAxis) SIP_HOLDGIL
Sets the semi-major axis.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
virtual bool operator==(const QgsEllipse &elp) const