18 QgsAABB::QgsAABB(
float xMin,
float yMin,
float zMin,
float xMax,
float yMax,
float zMax )
27 if ( this->xMax < this->
xMin )
28 std::swap( this->xMin, this->xMax );
29 if ( this->yMax < this->
yMin )
30 std::swap( this->yMin, this->yMax );
31 if ( this->zMax < this->
zMin )
32 std::swap( this->zMin, this->zMax );
44 return xMin <= x && xMax >= x &&
45 yMin <= y && yMax >= y &&
46 zMin <= z && zMax >= z;
52 const float dx = std::max(
xMin - x, std::max( 0.f, x -
xMax ) );
53 const float dy = std::max(
yMin - y, std::max( 0.f, y -
yMax ) );
54 const float dz = std::max(
zMin - z, std::max( 0.f, z -
zMax ) );
55 return sqrt( dx * dx + dy * dy + dz * dz );
65 QList<QVector3D> vertices;
66 for (
int i = 0; i < 2; ++i )
69 for (
int j = 0; j < 2; ++j )
72 for (
int k = 0; k < 2; ++k )
77 vertices.append( QVector3D(
xMin, y, z ) );
78 vertices.append( QVector3D(
xMax, y, z ) );
82 vertices.append( QVector3D( x,
yMin, z ) );
83 vertices.append( QVector3D( x,
yMax, z ) );
87 vertices.append( QVector3D( x, y,
zMin ) );
88 vertices.append( QVector3D( x, y,
zMax ) );
98 return QStringLiteral(
"X %1 - %2 Y %3 - %4 Z %5 - %6" ).arg(
xMin ).arg(
xMax ).arg(
yMin ).arg(
yMax ).arg(
zMin ).arg(
zMax );
QList< QVector3D > verticesForLines() const
Returns a list of pairs of vertices (useful for display of bounding boxes)
QString toString() const
Returns text representation of the bounding box.
bool intersects(const QgsAABB &other) const
Determines whether the box intersects some other axis aligned box.
float distanceFromPoint(float x, float y, float z) const
Returns shortest distance from the box to a point.
QgsAABB()=default
Constructs bounding box with null coordinates.