QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
QgsEllipse Class Reference

Ellipse geometry type. More...

#include <qgsellipse.h>

Inheritance diagram for QgsEllipse:
Inheritance graph
[legend]

Public Member Functions

 QgsEllipse () SIP_HOLDGIL=default
 Constructor for QgsEllipse. More...
 
 QgsEllipse (const QgsPoint &center, double semiMajorAxis, double semiMinorAxis, double azimuth=90) SIP_HOLDGIL
 Constructs an ellipse by defining all the members. More...
 
virtual ~QgsEllipse ()=default
 
virtual double area () const SIP_HOLDGIL
 The area of the ellipse. More...
 
double azimuth () const SIP_HOLDGIL
 Returns the azimuth. More...
 
virtual QgsRectangle boundingBox () const
 Returns the minimal bounding box for the ellipse. More...
 
QgsPoint center () const SIP_HOLDGIL
 Returns the center point. More...
 
virtual double eccentricity () const SIP_HOLDGIL
 The eccentricity of the ellipse. More...
 
virtual QVector< QgsPointfoci () const
 Two foci of the ellipse. More...
 
virtual double focusDistance () const SIP_HOLDGIL
 The distance between the center and each foci. More...
 
virtual bool isEmpty () const SIP_HOLDGIL
 An ellipse is empty if axes are equal to 0. More...
 
virtual bool operator!= (const QgsEllipse &elp) const
 
virtual bool operator== (const QgsEllipse &elp) const
 
virtual QgsPolygonorientedBoundingBox () const
 Returns the oriented minimal bounding box for the ellipse. More...
 
virtual double perimeter () const SIP_HOLDGIL
 The circumference of the ellipse using first approximation of Ramanujan. More...
 
virtual QgsPointSequence points (unsigned int segments=36) const
 Returns a list of points with segmentation from segments. More...
 
virtual QVector< QgsPointquadrant () const
 The four quadrants of the ellipse. More...
 
QgsPointrcenter ()
 Returns a reference to the center point of this ellipse. More...
 
double semiMajorAxis () const SIP_HOLDGIL
 Returns the semi-major axis. More...
 
double semiMinorAxis () const SIP_HOLDGIL
 Returns the semi-minor axis. More...
 
void setAzimuth (double azimuth) SIP_HOLDGIL
 Sets the azimuth (orientation). More...
 
void setCenter (const QgsPoint &center) SIP_HOLDGIL
 Sets the center point. More...
 
virtual void setSemiMajorAxis (double semiMajorAxis) SIP_HOLDGIL
 Sets the semi-major axis. More...
 
virtual void setSemiMinorAxis (double semiMinorAxis) SIP_HOLDGIL
 Sets the semi-minor axis. More...
 
virtual QgsLineStringtoLineString (unsigned int segments=36) const
 Returns a segmented linestring. More...
 
virtual QgsPolygontoPolygon (unsigned int segments=36) const
 Returns a segmented polygon. More...
 
virtual QString toString (int pointPrecision=17, int axisPrecision=17, int azimuthPrecision=2) const
 returns a string representation of the ellipse. More...
 

Static Public Member Functions

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. More...
 
static QgsEllipse fromCenterPoint (const QgsPoint &ptc, const QgsPoint &pt1) SIP_HOLDGIL
 Constructs an ellipse by a center point and a another point. More...
 
static QgsEllipse fromExtent (const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
 Constructs an ellipse by an extent (aka bounding box / QgsRectangle). More...
 
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. More...
 

Protected Attributes

double mAzimuth = 90.0
 
QgsPoint mCenter
 
double mSemiMajorAxis = 0.0
 
double mSemiMinorAxis = 0.0
 

Detailed Description

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.

Since
QGIS 3.0

Definition at line 39 of file qgsellipse.h.

Constructor & Destructor Documentation

◆ QgsEllipse() [1/2]

QgsEllipse::QgsEllipse ( )
default

Constructor for QgsEllipse.

◆ ~QgsEllipse()

virtual QgsEllipse::~QgsEllipse ( )
virtualdefault

◆ QgsEllipse() [2/2]

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

Constructs an ellipse by defining all the members.

Parameters
centerThe center of the ellipse.
semiMajorAxisSemi-major axis of the ellipse.
semiMinorAxisSemi-minor axis of the ellipse.
azimuthAngle in degrees started from the North to the first quadrant.

Definition at line 38 of file qgsellipse.cpp.

Member Function Documentation

◆ area()

double QgsEllipse::area ( ) const
virtual

The area of the ellipse.

Reimplemented in QgsCircle.

Definition at line 165 of file qgsellipse.cpp.

◆ azimuth()

double QgsEllipse::azimuth ( ) const
inline

Returns the azimuth.

See also
setAzimuth()

Definition at line 139 of file qgsellipse.h.

◆ boundingBox()

QgsRectangle QgsEllipse::boundingBox ( ) const
virtual

Returns the minimal bounding box for the ellipse.

Reimplemented in QgsCircle.

Definition at line 254 of file qgsellipse.cpp.

◆ center()

QgsPoint QgsEllipse::center ( ) const
inline

Returns the center point.

See also
setCenter()
rcenter()

Definition at line 121 of file qgsellipse.h.

◆ eccentricity()

double QgsEllipse::eccentricity ( ) const
virtual

The eccentricity of the ellipse.

nan is returned if the ellipse is empty.

Definition at line 156 of file qgsellipse.cpp.

◆ foci()

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

Two foci of the ellipse.

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

See also
fromFoci()
focusDistance()
Returns
the two foci.

Definition at line 146 of file qgsellipse.cpp.

◆ focusDistance()

double QgsEllipse::focusDistance ( ) const
virtual

The distance between the center and each foci.

See also
fromFoci()
foci()
Returns
The distance between the center and each foci.

Definition at line 141 of file qgsellipse.cpp.

◆ fromCenter2Points()

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

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
ptcCenter point.
pt1First point.
pt2Second point.

Definition at line 89 of file qgsellipse.cpp.

◆ fromCenterPoint()

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

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
ptcCenter point.
pt1First point.

Definition at line 77 of file qgsellipse.cpp.

◆ fromExtent()

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

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
pt1First corner.
pt2Second corner.

Definition at line 65 of file qgsellipse.cpp.

◆ fromFoci()

QgsEllipse QgsEllipse::fromFoci ( const QgsPoint pt1,
const QgsPoint pt2,
const QgsPoint pt3 
)
static

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
pt1First focus.
pt2Second focus.
pt3A point to calculate the axes.

Definition at line 47 of file qgsellipse.cpp.

◆ isEmpty()

bool QgsEllipse::isEmpty ( ) const
virtual

An ellipse is empty if axes are equal to 0.

Definition at line 118 of file qgsellipse.cpp.

◆ operator!=()

bool QgsEllipse::operator!= ( const QgsEllipse elp) const
virtual

Definition at line 113 of file qgsellipse.cpp.

◆ operator==()

bool QgsEllipse::operator== ( const QgsEllipse elp) const
virtual

Definition at line 104 of file qgsellipse.cpp.

◆ orientedBoundingBox()

QgsPolygon * QgsEllipse::orientedBoundingBox ( ) const
virtual

Returns the oriented minimal bounding box for the ellipse.

Definition at line 292 of file qgsellipse.cpp.

◆ perimeter()

double QgsEllipse::perimeter ( ) const
virtual

The circumference of the ellipse using first approximation of Ramanujan.

Reimplemented in QgsCircle.

Definition at line 170 of file qgsellipse.cpp.

◆ points()

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

Returns a list of points with segmentation from segments.

Parameters
segmentsNumber of segments used to segment geometry.

Definition at line 188 of file qgsellipse.cpp.

◆ quadrant()

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

The four quadrants of the ellipse.

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

Returns
quadrants defined by four points.

Definition at line 177 of file qgsellipse.cpp.

◆ rcenter()

QgsPoint& QgsEllipse::rcenter ( )
inline

Returns a reference to the center point of this ellipse.

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

See also
center()
setCenter()
Note
not available in Python bindings

Definition at line 148 of file qgsellipse.h.

◆ semiMajorAxis()

double QgsEllipse::semiMajorAxis ( ) const
inline

Returns the semi-major axis.

See also
setSemiMajorAxis()

Definition at line 127 of file qgsellipse.h.

◆ semiMinorAxis()

double QgsEllipse::semiMinorAxis ( ) const
inline

Returns the semi-minor axis.

See also
setSemiMinorAxis()

Definition at line 133 of file qgsellipse.h.

◆ setAzimuth()

void QgsEllipse::setAzimuth ( double  azimuth)

Sets the azimuth (orientation).

See also
azimuth()

Definition at line 135 of file qgsellipse.cpp.

◆ setCenter()

void QgsEllipse::setCenter ( const QgsPoint center)
inline

Sets the center point.

See also
center()
rcenter()

Definition at line 155 of file qgsellipse.h.

◆ setSemiMajorAxis()

void QgsEllipse::setSemiMajorAxis ( double  semiMajorAxis)
virtual

Sets the semi-major axis.

See also
semiMajorAxis()

Reimplemented in QgsCircle.

Definition at line 124 of file qgsellipse.cpp.

◆ setSemiMinorAxis()

void QgsEllipse::setSemiMinorAxis ( double  semiMinorAxis)
virtual

Sets the semi-minor axis.

See also
semiMinorAxis()

Reimplemented in QgsCircle.

Definition at line 129 of file qgsellipse.cpp.

◆ toLineString()

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

Returns a segmented linestring.

Parameters
segmentsNumber of segments used to segment geometry.

Definition at line 237 of file qgsellipse.cpp.

◆ toPolygon()

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

Returns a segmented polygon.

Parameters
segmentsNumber of segments used to segment geometry.

Definition at line 224 of file qgsellipse.cpp.

◆ toString()

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.

Reimplemented in QgsCircle.

Definition at line 277 of file qgsellipse.cpp.

Member Data Documentation

◆ mAzimuth

double QgsEllipse::mAzimuth = 90.0
protected

Definition at line 255 of file qgsellipse.h.

◆ mCenter

QgsPoint QgsEllipse::mCenter
protected

Definition at line 252 of file qgsellipse.h.

◆ mSemiMajorAxis

double QgsEllipse::mSemiMajorAxis = 0.0
protected

Definition at line 253 of file qgsellipse.h.

◆ mSemiMinorAxis

double QgsEllipse::mSemiMinorAxis = 0.0
protected

Definition at line 254 of file qgsellipse.h.


The documentation for this class was generated from the following files: