QgsEllipse class

Ellipse geometry type.

An ellipse is defined by a center point with a semi-major axis, a semi-minor axis and an azimuth. The azimuth is the north angle to the first quadrant (always oriented on the semi-major axis), in degrees. By default, the semi-major axis is oriented to the east (90 degrees). The semi-minor axis is always smaller than the semi-major axis. If it is set larger, it will be swapped and the azimuth will increase by 90 degrees.

Derived classes

class QgsCircle
Circle geometry type.

Public static functions

static auto fromCenter2Points(const QgsPoint& ptc, const QgsPoint& pt1, const QgsPoint& pt2) -> QgsEllipse
Constructs an ellipse by a central point and two other points.
static auto fromCenterPoint(const QgsPoint& ptc, const QgsPoint& pt1) -> QgsEllipse
Constructs an ellipse by a center point and a another point.
static auto fromExtent(const QgsPoint& pt1, const QgsPoint& pt2) -> QgsEllipse
Constructs an ellipse by an extent (aka bounding box / QgsRectangle).
static auto fromFoci(const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3) -> QgsEllipse
Constructs an ellipse by foci (pt1 and pt2) and a point pt3.

Constructors, destructors, conversion operators

QgsEllipse() defaulted
Constructor for QgsEllipse.
QgsEllipse(const QgsPoint& center, double semiMajorAxis, double semiMinorAxis, double azimuth = 90)
Constructs an ellipse by defining all the members.

Public functions

auto area() const -> double virtual
The area of the ellipse.
auto azimuth() const -> double
Returns the azimuth.
auto boundingBox() const -> QgsRectangle virtual
Returns the minimal bounding box for the ellipse.
auto center() const -> QgsPoint
Returns the center point.
auto eccentricity() const -> double virtual
The eccentricity of the ellipse.
auto foci() const -> QVector<QgsPoint> virtual
Two foci of the ellipse.
auto focusDistance() const -> double virtual
The distance between the center and each foci.
auto isEmpty() const -> bool virtual
An ellipse is empty if axes are equal to 0.
auto orientedBoundingBox() const -> QgsPolygon* virtual
Returns the oriented minimal bounding box for the ellipse.
auto perimeter() const -> double virtual
The circumference of the ellipse using first approximation of Ramanujan.
auto points(unsigned int segments = 36) const -> QgsPointSequence virtual
Returns a list of points with segmentation from segments.
auto quadrant() const -> QVector<QgsPoint> virtual
The four quadrants of the ellipse.
auto rcenter() -> QgsPoint&
Returns a reference to the center point of this ellipse.
auto semiMajorAxis() const -> double
Returns the semi-major axis.
auto semiMinorAxis() const -> double
Returns the semi-minor axis.
void setAzimuth(double azimuth)
Sets the azimuth (orientation).
void setCenter(const QgsPoint& center)
Sets the center point.
void setSemiMajorAxis(double semiMajorAxis) virtual
Sets the semi-major axis.
void setSemiMinorAxis(double semiMinorAxis) virtual
Sets the semi-minor axis.
auto toLineString(unsigned int segments = 36) const -> QgsLineString* virtual
Returns a segmented linestring.
auto toPolygon(unsigned int segments = 36) const -> QgsPolygon* virtual
Returns a segmented polygon.
auto toString(int pointPrecision = 17, int axisPrecision = 17, int azimuthPrecision = 2) const -> QString virtual
returns a string representation of the ellipse.

Function documentation

static QgsEllipse QgsEllipse::fromCenter2Points(const QgsPoint& ptc, const QgsPoint& pt1, const QgsPoint& pt2)

Constructs an ellipse by a central point and two other points.

Parameters
ptc Center point.
pt1 First point.
pt2 Second point.

The center point keeps m value from ptc. Z dimension is also supported and is retrieved from the first 3D point amongst ptc, pt1 and pt2. Axes are calculated from the 2D distance between ptc and pt1 and pt2. The azimuth is the angle between ptc and pt1.

static QgsEllipse QgsEllipse::fromCenterPoint(const QgsPoint& ptc, const QgsPoint& pt1)

Constructs an ellipse by a center point and a another point.

Parameters
ptc Center point.
pt1 First point.

The center point keeps m value from ptc. Z dimension is also supported and is retrieved from the first 3D point amongst ptc and pt1. Axes are calculated from the 2D distance between ptc and pt1. The azimuth always takes the default value.

static QgsEllipse QgsEllipse::fromExtent(const QgsPoint& pt1, const QgsPoint& pt2)

Constructs an ellipse 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 QgsEllipse QgsEllipse::fromFoci(const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3)

Constructs an ellipse by foci (pt1 and pt2) and a point pt3.

Parameters
pt1 First focus.
pt2 Second focus.
pt3 A point to calculate the axes.

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 with the third point pt3. The azimuth is the angle between pt1 and pt2.

QgsEllipse::QgsEllipse(const QgsPoint& center, double semiMajorAxis, double semiMinorAxis, double azimuth = 90)

Constructs an ellipse by defining all the members.

Parameters
center The center of the ellipse.
semiMajorAxis Semi-major axis of the ellipse.
semiMinorAxis Semi-minor axis of the ellipse.
azimuth Angle in degrees started from the North to the first quadrant.

double QgsEllipse::azimuth() const

Returns the azimuth.

QgsPoint QgsEllipse::center() const

Returns the center point.

double QgsEllipse::eccentricity() const virtual

The eccentricity of the ellipse.

nan is returned if the ellipse is empty.

QVector<QgsPoint> QgsEllipse::foci() const virtual

Two foci of the ellipse.

Returns the two foci.

The axes are oriented by the azimuth and are on the semi-major axis.

double QgsEllipse::focusDistance() const virtual

The distance between the center and each foci.

Returns The distance between the center and each foci.

QgsPointSequence QgsEllipse::points(unsigned int segments = 36) const virtual

Returns a list of points with segmentation from segments.

Parameters
segments Number of segments used to segment geometry.

QVector<QgsPoint> QgsEllipse::quadrant() const virtual

The four quadrants of the ellipse.

Returns quadrants defined by four points.

They are oriented and started always from semi-major axis.

QgsPoint& QgsEllipse::rcenter()

Returns a reference to the center point of this ellipse.

Using a reference makes it possible to directly manipulate center in place.

double QgsEllipse::semiMajorAxis() const

Returns the semi-major axis.

double QgsEllipse::semiMinorAxis() const

Returns the semi-minor axis.

void QgsEllipse::setAzimuth(double azimuth)

Sets the azimuth (orientation).

void QgsEllipse::setCenter(const QgsPoint& center)

Sets the center point.

void QgsEllipse::setSemiMajorAxis(double semiMajorAxis) virtual

Sets the semi-major axis.

void QgsEllipse::setSemiMinorAxis(double semiMinorAxis) virtual

Sets the semi-minor axis.

QgsLineString* QgsEllipse::toLineString(unsigned int segments = 36) const virtual

Returns a segmented linestring.

Parameters
segments Number of segments used to segment geometry.

QgsPolygon* QgsEllipse::toPolygon(unsigned int segments = 36) const virtual

Returns a segmented polygon.

Parameters
segments Number of segments used to segment geometry.

QString QgsEllipse::toString(int pointPrecision = 17, int axisPrecision = 17, int azimuthPrecision = 2) const virtual

returns a string representation of the ellipse.

Members will be truncated to the specified precision.