QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
geometry
qgssphere.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgssphere.h
3
--------------
4
begin : July 2023
5
copyright : (C) 2023 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#ifndef QGSSPHERE_H
19
#define QGSSPHERE_H
20
21
#include <limits>
22
23
#include "
qgis.h
"
24
#include "qgis_core.h"
25
#include "
qgis_sip.h
"
26
27
#include <QString>
28
29
using namespace
Qt::StringLiterals;
30
31
class
QgsPoint
;
32
class
QgsCircle
;
33
class
QgsBox3D
;
34
class
QgsVector3D
;
35
45
class
CORE_EXPORT
QgsSphere
46
{
47
public
:
48
// clang-format off
52
QgsSphere
()
SIP_HOLDGIL
= default;
53
// clang-format on
54
58
QgsSphere
(
double
x,
double
y,
double
z,
double
radius
)
SIP_HOLDGIL
;
59
60
bool
operator==( const
QgsSphere
&other )
const
61
{
62
return
qgsDoubleNear
( mCenterX, other.mCenterX ) &&
qgsDoubleNear
( mCenterY, other.mCenterY ) &&
qgsDoubleNear
( mCenterZ, other.mCenterZ ) &&
qgsDoubleNear
( mRadius, other.mRadius );
63
}
64
bool
operator!=
(
const
QgsSphere
&other )
const
{
return
!( *
this
== other ); }
65
69
bool
isNull() const
SIP_HOLDGIL
;
70
74
bool
isEmpty() const
SIP_HOLDGIL
;
75
84
QgsPoint
center() const
SIP_HOLDGIL
;
85
94
QgsVector3D
centerVector() const
SIP_HOLDGIL
;
95
104
double
centerX
()
const
{
return
mCenterX; }
105
114
double
centerY
()
const
{
return
mCenterY; }
115
124
double
centerZ
()
const
{
return
mCenterZ; }
125
130
void
setCenter(
const
QgsPoint
¢er )
SIP_HOLDGIL
;
131
136
void
setCenter
(
double
x,
double
y,
double
z )
SIP_HOLDGIL
{ mCenterX = x; mCenterY = y; mCenterZ = z; }
137
144
double
radius
() const
SIP_HOLDGIL
{
return
mRadius; }
145
151
void
setRadius
(
double
radius
)
SIP_HOLDGIL
{ mRadius =
radius
; }
152
158
double
diameter
() const
SIP_HOLDGIL
{
return
mRadius * 2; }
159
163
double
volume() const
SIP_HOLDGIL
;
164
168
double
surfaceArea() const
SIP_HOLDGIL
;
169
173
QgsCircle
toCircle() const
SIP_HOLDGIL
;
174
178
QgsBox3D
boundingBox() const
SIP_HOLDGIL
;
179
180
#ifdef SIP_RUN
181
// clang-format off
182
SIP_PYOBJECT __repr__();
183
% MethodCode
184
QString str;
185
if
( sipCpp->isNull() )
186
{
187
str = u
"<QgsSphere: null>"
_s.arg( sipCpp->centerX() ).arg( sipCpp->centerY() ).arg( sipCpp->centerZ() ).arg( sipCpp->radius() );
188
}
189
else
190
{
191
str = u
"<QgsSphere: (%1, %2, %3) radius %4>"
_s.arg( sipCpp->centerX() ).arg( sipCpp->centerY() ).arg( sipCpp->centerZ() ).arg( sipCpp->radius() );
192
}
193
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
194
% End
195
// clang-format on
196
#endif
197
198
private
:
199
double
mCenterX = std::numeric_limits< double >::quiet_NaN();
200
double
mCenterY = std::numeric_limits< double >::quiet_NaN();
201
double
mCenterZ = std::numeric_limits< double >::quiet_NaN();
202
double
mRadius = 0;
203
204
};
205
206
#endif
// QGSSPHERE_H
QgsBox3D
A 3-dimensional box composed of x, y, z coordinates.
Definition
qgsbox3d.h:45
QgsCircle
Circle geometry type.
Definition
qgscircle.h:46
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition
qgspoint.h:53
QgsSphere::QgsSphere
QgsSphere()=default
Constructor for an invalid QgsSphere.
QgsSphere::centerY
double centerY() const
Returns the y-coordinate of the center of the sphere.
Definition
qgssphere.h:114
QgsSphere::radius
double radius() const
Returns the radius of the sphere.
Definition
qgssphere.h:144
QgsSphere::diameter
double diameter() const
Returns the diameter of the sphere.
Definition
qgssphere.h:158
QgsSphere::setCenter
void setCenter(double x, double y, double z)
Sets the center point of the sphere to (x, y, z).
Definition
qgssphere.h:136
QgsSphere::operator!=
bool operator!=(const QgsSphere &other) const
Definition
qgssphere.h:64
QgsSphere::centerZ
double centerZ() const
Returns the z-coordinate of the center of the sphere.
Definition
qgssphere.h:124
QgsSphere::setRadius
void setRadius(double radius)
Sets the radius of the sphere.
Definition
qgssphere.h:151
QgsSphere::centerX
double centerX() const
Returns the x-coordinate of the center of the sphere.
Definition
qgssphere.h:104
QgsVector3D
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition
qgsvector3d.h:33
qgis.h
qgsDoubleNear
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition
qgis.h:7743
qgis_sip.h
SIP_HOLDGIL
#define SIP_HOLDGIL
Definition
qgis_sip.h:183
Generated on
for QGIS API Documentation by
1.17.0