QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsaabb.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsaabb.h
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSAABB_H
17 #define QGSAABB_H
18 
19 #include "qgis_3d.h"
20 
21 #include <cmath>
22 #include <QList>
23 #include <QVector3D>
24 
25 #define SIP_NO_FILE
26 
33 class _3D_EXPORT QgsAABB
34 {
35  public:
37  QgsAABB() = default;
38 
40  QgsAABB( float xMin, float yMin, float zMin, float xMax, float yMax, float zMax );
41 
43  float xExtent() const { return xMax - xMin; }
45  float yExtent() const { return yMax - yMin; }
47  float zExtent() const { return zMax - zMin; }
48 
50  float xCenter() const { return ( xMax + xMin ) / 2; }
52  float yCenter() const { return ( yMax + yMin ) / 2; }
54  float zCenter() const { return ( zMax + zMin ) / 2; }
55 
57  QVector3D center() const { return QVector3D( xCenter(), yCenter(), zCenter() ); }
59  QVector3D minimum() const { return QVector3D( xMin, yMin, zMin ); }
61  QVector3D maximum() const { return QVector3D( xMax, yMax, zMax ); }
62 
64  bool intersects( const QgsAABB &other ) const;
65 
67  bool intersects( float x, float y, float z ) const;
68 
70  float distanceFromPoint( float x, float y, float z ) const;
71 
73  float distanceFromPoint( QVector3D v ) const;
74 
76  QList<QVector3D> verticesForLines() const;
77 
79  QString toString() const;
80 
81  float xMin = 0.0f;
82  float yMin = 0.0f;
83  float zMin = 0.0f;
84  float xMax = 0.0f;
85  float yMax = 0.0f;
86  float zMax = 0.0f;
87 };
88 
89 #endif // QGSAABB_H
3
Definition: qgsaabb.h:34
float yExtent() const
Returns box width in Y axis.
Definition: qgsaabb.h:45
QVector3D center() const
Returns coordinates of the center of the box.
Definition: qgsaabb.h:57
float xExtent() const
Returns box width in X axis.
Definition: qgsaabb.h:43
float xCenter() const
Returns center in X axis.
Definition: qgsaabb.h:50
float zExtent() const
Returns box width in Z axis.
Definition: qgsaabb.h:47
QVector3D minimum() const
Returns corner of the box with minimal coordinates.
Definition: qgsaabb.h:59
float yCenter() const
Returns center in Y axis.
Definition: qgsaabb.h:52
QgsAABB()=default
Constructs bounding box with null coordinates.
QVector3D maximum() const
Returns corner of the box with maximal coordinates.
Definition: qgsaabb.h:61
float zCenter() const
Returns center in Z axis.
Definition: qgsaabb.h:54