Class: QgsEllipse

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.

Class Hierarchy

Inheritance diagram of qgis.core.QgsEllipse

Subclasses

QgsCircle

Circle geometry type.

Methods

azimuth

Returns the azimuth.

center

Returns the center point.

semiMajorAxis

Returns the semi-major axis.

semiMinorAxis

Returns the semi-minor axis.

setAzimuth

Sets the azimuth (orientation).

setCenter

Sets the center point.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsEllipse. See the FAQ for more details.

area

The area of the ellipse.

boundingBox

Returns the minimal bounding box for the ellipse.

eccentricity

The eccentricity of the ellipse.

foci

Two foci of the ellipse.

focusDistance

The distance between the center and each foci.

isEmpty

An ellipse is empty if axes are equal to 0

orientedBoundingBox

Returns the oriented minimal bounding box for the ellipse.

perimeter

The circumference of the ellipse using first approximation of Ramanujan.

points

Returns a list of points with segmentation from segments.

quadrant

The four quadrants of the ellipse.

setSemiMajorAxis

Sets the semi-major axis.

setSemiMinorAxis

Sets the semi-minor axis.

toLineString

Returns a segmented linestring.

toPolygon

Returns a segmented polygon.

toString

returns a string representation of the ellipse.

Static Methods

fromCenter2Points

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

fromCenterPoint

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

fromExtent

Constructs an ellipse by an extent (aka bounding box / QgsRectangle).

fromFoci

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

class qgis.core.QgsEllipse[source]

Bases: object

__init__()

Constructor for QgsEllipse.

__init__(center: QgsPoint, semiMajorAxis: float, semiMinorAxis: float, azimuth: float = 90)

Constructs an ellipse by defining all the members.

Parameters:
  • center (QgsPoint) – The center of the ellipse.

  • semiMajorAxis (float) – Semi-major axis of the ellipse.

  • semiMinorAxis (float) – Semi-minor axis of the ellipse.

  • azimuth (float = 90) – Angle in degrees started from the North to the first quadrant.

__init__(a0: QgsEllipse)
Parameters:

a0 (QgsEllipse)

virtual area(self) float[source]

The area of the ellipse.

Return type:

float

azimuth(self) float[source]

Returns the azimuth.

See also

setAzimuth()

Return type:

float

virtual boundingBox(self) QgsRectangle[source]

Returns the minimal bounding box for the ellipse.

Return type:

QgsRectangle

center(self) QgsPoint[source]

Returns the center point.

See also

setCenter()

See also

rcenter()

Return type:

QgsPoint

virtual eccentricity(self) float[source]

The eccentricity of the ellipse. nan is returned if the ellipse is empty.

Return type:

float

virtual foci(self) List[QgsPoint]

Two foci of the ellipse. The axes are oriented by the azimuth and are on the semi-major axis.

See also

fromFoci()

See also

focusDistance()

Return type:

List[QgsPoint]

Returns:

the two foci.

virtual focusDistance(self) float[source]

The distance between the center and each foci.

See also

fromFoci()

See also

foci()

Return type:

float

Returns:

The distance between the center and each foci.

static fromCenter2Points(ptc: QgsPoint, pt1: QgsPoint, pt2: QgsPoint) QgsEllipse[source]

Constructs an ellipse by a central point and two other points. 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.

Parameters:
Return type:

QgsEllipse

static fromCenterPoint(ptc: QgsPoint, pt1: QgsPoint) QgsEllipse[source]

Constructs an ellipse by a center point and a another 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.

Parameters:
Return type:

QgsEllipse

static fromExtent(pt1: QgsPoint, pt2: QgsPoint) QgsEllipse[source]

Constructs an ellipse 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.

Parameters:
Return type:

QgsEllipse

static fromFoci(pt1: QgsPoint, pt2: QgsPoint, pt3: QgsPoint) QgsEllipse[source]

Constructs an ellipse by foci (pt1 and pt2) and a point pt3. 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.

Parameters:
Return type:

QgsEllipse

virtual isEmpty(self) bool[source]

An ellipse is empty if axes are equal to 0

Return type:

bool

virtual orientedBoundingBox(self) QgsPolygon | None[source]

Returns the oriented minimal bounding box for the ellipse.

Return type:

Optional[QgsPolygon]

virtual perimeter(self) float[source]

The circumference of the ellipse using first approximation of Ramanujan.

Return type:

float

virtual points(self, segments: int = 36) List[QgsPoint][source]

Returns a list of points with segmentation from segments.

Parameters:

segments (int = 36) – Number of segments used to segment geometry.

Return type:

List[QgsPoint]

virtual quadrant(self) List[QgsPoint]

The four quadrants of the ellipse. They are oriented and started always from semi-major axis.

Return type:

List[QgsPoint]

Returns:

quadrants defined by four points.

semiMajorAxis(self) float[source]

Returns the semi-major axis.

Return type:

float

semiMinorAxis(self) float[source]

Returns the semi-minor axis.

Return type:

float

setAzimuth(self, azimuth: float)[source]

Sets the azimuth (orientation).

See also

azimuth()

Parameters:

azimuth (float)

setCenter(self, center: QgsPoint)[source]

Sets the center point.

See also

center()

See also

rcenter()

Parameters:

center (QgsPoint)

virtual setSemiMajorAxis(self, semiMajorAxis: float)[source]

Sets the semi-major axis.

See also

semiMajorAxis()

Parameters:

semiMajorAxis (float)

virtual setSemiMinorAxis(self, semiMinorAxis: float)[source]

Sets the semi-minor axis.

See also

semiMinorAxis()

Parameters:

semiMinorAxis (float)

virtual toLineString(self, segments: int = 36) QgsLineString | None[source]

Returns a segmented linestring.

Parameters:

segments (int = 36) – Number of segments used to segment geometry.

Return type:

Optional[QgsLineString]

virtual toPolygon(self, segments: int = 36) QgsPolygon | None[source]

Returns a segmented polygon.

Parameters:

segments (int = 36) – Number of segments used to segment geometry.

Return type:

Optional[QgsPolygon]

virtual toString(self, pointPrecision: int = 17, axisPrecision: int = 17, azimuthPrecision: int = 2) str[source]

returns a string representation of the ellipse. Members will be truncated to the specified precision.

Parameters:
  • pointPrecision (int = 17)

  • axisPrecision (int = 17)

  • azimuthPrecision (int = 2)

Return type:

str