QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsorientedbox3d.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsorientedbox3d.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 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#ifndef QGSORIENTEDBOX3D_H
20#define QGSORIENTEDBOX3D_H
21
22#include <limits>
23
24#include "qgis.h"
25#include "qgis_core.h"
26#include "qgis_sip.h"
27#include "qgsvector3d.h"
28
29#include <QList>
30
31class QgsBox3D;
33class QgsMatrix4x4;
34
44class CORE_EXPORT QgsOrientedBox3D
45{
46 public:
47
52
56 QgsOrientedBox3D( const QList<double> &center, const QList< double > &halfAxes );
57
61 QgsOrientedBox3D( const QgsVector3D &center, const QList< QgsVector3D > &halfAxes );
62
67 QgsOrientedBox3D( const QgsVector3D &center, const QgsVector3D &halfSizes, const QQuaternion &quaternion );
68
72 static QgsOrientedBox3D fromBox3D( const QgsBox3D &box );
73
74 bool operator==( const QgsOrientedBox3D &other ) const SIP_HOLDGIL
75 {
76 return qgsDoubleNear( mCenter[0], other.mCenter[0] )
77 && qgsDoubleNear( mCenter[1], other.mCenter[1] )
78 && qgsDoubleNear( mCenter[2], other.mCenter[2] )
79 && qgsDoubleNear( mHalfAxes[0], other.mHalfAxes[0] )
80 && qgsDoubleNear( mHalfAxes[1], other.mHalfAxes[1] )
81 && qgsDoubleNear( mHalfAxes[2], other.mHalfAxes[2] )
82 && qgsDoubleNear( mHalfAxes[3], other.mHalfAxes[3] )
83 && qgsDoubleNear( mHalfAxes[4], other.mHalfAxes[4] )
84 && qgsDoubleNear( mHalfAxes[5], other.mHalfAxes[5] )
85 && qgsDoubleNear( mHalfAxes[6], other.mHalfAxes[6] )
86 && qgsDoubleNear( mHalfAxes[7], other.mHalfAxes[7] )
87 && qgsDoubleNear( mHalfAxes[8], other.mHalfAxes[8] );
88 }
89
90 bool operator!=( const QgsOrientedBox3D &other ) const SIP_HOLDGIL
91 {
92 return !( *this == other );
93 }
94
98 bool isNull() const SIP_HOLDGIL;
99
106 double centerX() const SIP_HOLDGIL { return mCenter[0]; }
107
114 double centerY() const SIP_HOLDGIL { return mCenter[1]; }
115
122 double centerZ() const SIP_HOLDGIL { return mCenter[2]; }
123
127 QgsVector3D center() const SIP_HOLDGIL { return QgsVector3D( mCenter[0], mCenter[1], mCenter[2] ); }
128
132 const double *halfAxes() const SIP_SKIP { return mHalfAxes; }
133
137 QList< double > halfAxesList() const SIP_HOLDGIL SIP_PYNAME( halfAxes );
138
142 QgsBox3D extent() const SIP_HOLDGIL;
143
147 QVector< QgsVector3D > corners() const SIP_HOLDGIL;
148
152 QgsVector3D size() const SIP_HOLDGIL;
153
158 double longestSide() const SIP_HOLDGIL;
159
165 QgsBox3D reprojectedExtent( const QgsCoordinateTransform &ct ) const SIP_THROW( QgsCsException ) SIP_HOLDGIL;
166
170 QgsOrientedBox3D transformed( const QgsMatrix4x4 &transform ) const SIP_HOLDGIL;
171
175 bool intersects( const QgsOrientedBox3D &other ) const SIP_HOLDGIL;
176
177#ifdef SIP_RUN
178 SIP_PYOBJECT __repr__();
179 % MethodCode
180 QString str = QStringLiteral( "<QgsOrientedBox3D([%1, %2, %3], [%4, %5, %6, %7, %8, %9, %10, %11, %12])>" )
181 .arg( sipCpp->centerX() )
182 .arg( sipCpp->centerY() )
183 .arg( sipCpp->centerZ() )
184 .arg( sipCpp->halfAxes()[0] )
185 .arg( sipCpp->halfAxes()[1] )
186 .arg( sipCpp->halfAxes()[2] )
187 .arg( sipCpp->halfAxes()[3] )
188 .arg( sipCpp->halfAxes()[4] )
189 .arg( sipCpp->halfAxes()[5] )
190 .arg( sipCpp->halfAxes()[6] )
191 .arg( sipCpp->halfAxes()[7] )
192 .arg( sipCpp->halfAxes()[8] );
193 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
194 % End
195#endif
196
197 private:
198
199 double mCenter[ 3 ] { std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN() };
200 double mHalfAxes[9] { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
201
202 friend class QgsCesiumUtils;
203
204};
205
206
207#endif // QGSORIENTEDBOX3D_H
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:42
Handles coordinate transforms between two coordinate systems.
Custom exception class for Coordinate Reference System related exceptions.
A simple 4x4 matrix implementation useful for transformation in 3D space.
Represents a oriented (rotated) box in 3 dimensions.
const double * halfAxes() const
Returns the half axes matrix;.
friend class QgsCesiumUtils
double centerZ() const
Returns the center z-coordinate.
QgsOrientedBox3D()
Constructor for a null oriented box.
bool operator==(const QgsOrientedBox3D &other) const
bool operator!=(const QgsOrientedBox3D &other) const
static QgsOrientedBox3D fromBox3D(const QgsBox3D &box)
Constructs an oriented box from an axis-aligned bounding box.
double centerX() const
Returns the center x-coordinate.
double centerY() const
Returns the center y-coordinate.
QgsVector3D center() const
Returns the vector to the center of the box.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:30
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:6607
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_PYNAME(name)
Definition qgis_sip.h:89
#define SIP_HOLDGIL
Definition qgis_sip.h:179
#define SIP_THROW(name,...)
Definition qgis_sip.h:211