QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
78  float xMin = 0.0f;
79  float yMin = 0.0f;
80  float zMin = 0.0f;
81  float xMax = 0.0f;
82  float yMax = 0.0f;
83  float zMax = 0.0f;
84 };
85 
86 #endif // QGSAABB_H
QgsAABB::center
QVector3D center() const
Returns coordinates of the center of the box.
Definition: qgsaabb.h:57
QgsAABB::QgsAABB
QgsAABB()=default
Constructs bounding box with null coordinates.
QgsAABB::xExtent
float xExtent() const
Returns box width in X axis.
Definition: qgsaabb.h:43
QgsAABB::minimum
QVector3D minimum() const
Returns corner of the box with minimal coordinates.
Definition: qgsaabb.h:59
QgsAABB::yExtent
float yExtent() const
Returns box width in Y axis.
Definition: qgsaabb.h:45
QgsAABB::maximum
QVector3D maximum() const
Returns corner of the box with maximal coordinates.
Definition: qgsaabb.h:61
QgsAABB::yCenter
float yCenter() const
Returns center in Y axis.
Definition: qgsaabb.h:52
QgsAABB::zCenter
float zCenter() const
Returns center in Z axis.
Definition: qgsaabb.h:54
QgsAABB
3 Axis-aligned bounding box - in world coords.
Definition: qgsaabb.h:34
QgsAABB::xCenter
float xCenter() const
Returns center in X axis.
Definition: qgsaabb.h:50
QgsAABB::zExtent
float zExtent() const
Returns box width in Z axis.
Definition: qgsaabb.h:47