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 float dx = std::max(
xMin - x, std::max( 0.f, x -
xMax ) );
53 float dy = std::max(
yMin - y, std::max( 0.f, y -
yMax ) );
54 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 ) );
3 Axis-aligned bounding box - in world coords.
QgsAABB()=default
Constructs bounding box with null coordinates.
QList< QVector3D > verticesForLines() const
Returns a list of pairs of vertices (useful for display of bounding boxes)
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.