34 mCenter[0] =
center.at( 0 );
35 mCenter[1] =
center.at( 1 );
36 mCenter[2] =
center.at( 2 );
40 for (
int i = 0; i < 9; ++i )
54 for (
int i = 0; i < 3; ++i )
56 mHalfAxes[
static_cast< int >( i * 3 )] =
halfAxes.at( i ).x();
57 mHalfAxes[
static_cast< int >( i * 3 + 1 )] =
halfAxes.at( i ).y();
58 mHalfAxes[
static_cast< int >( i * 3 + 2 )] =
halfAxes.at( i ).z();
72 mHalfAxes[0] = v1.
x();
73 mHalfAxes[1] = v1.
y();
74 mHalfAxes[2] = v1.
z();
75 mHalfAxes[3] = v2.
x();
76 mHalfAxes[4] = v2.
y();
77 mHalfAxes[5] = v2.
z();
78 mHalfAxes[6] = v3.
x();
79 mHalfAxes[7] = v3.
y();
80 mHalfAxes[8] = v3.
z();
85 return QgsOrientedBox3D( box.
center(), QList< QgsVector3D > { QgsVector3D( box.width() * 0.5, 0, 0 ), QgsVector3D( 0, box.height() * 0.5, 0 ), QgsVector3D( 0, 0, box.depth() * 0.5 ) } );
90 return std::isnan( mCenter[0] ) || std::isnan( mCenter[1] ) || std::isnan( mCenter[2] );
97 for (
int i = 0; i < 9; ++i )
99 res.append( mHalfAxes[i] );
107 std::fabs( mHalfAxes[0] ) + std::fabs( mHalfAxes[3] ) + std::fabs( mHalfAxes[6] ),
108 std::fabs( mHalfAxes[1] ) + std::fabs( mHalfAxes[4] ) + std::fabs( mHalfAxes[7] ),
109 std::fabs( mHalfAxes[2] ) + std::fabs( mHalfAxes[5] ) + std::fabs( mHalfAxes[8] ),
112 const double minX = mCenter[0] -
extent[0];
113 const double maxX = mCenter[0] +
extent[0];
114 const double minY = mCenter[1] -
extent[1];
115 const double maxY = mCenter[1] +
extent[1];
116 const double minZ = mCenter[2] -
extent[2];
117 const double maxZ = mCenter[2] +
extent[2];
119 return QgsBox3D( minX, minY, minZ, maxX, maxY, maxZ );
125 const QgsVector3D a1( mHalfAxes[0], mHalfAxes[1], mHalfAxes[2] ), a0( -mHalfAxes[0], -mHalfAxes[1], -mHalfAxes[2] );
126 const QgsVector3D b1( mHalfAxes[3], mHalfAxes[4], mHalfAxes[5] ), b0( -mHalfAxes[3], -mHalfAxes[4], -mHalfAxes[5] );
127 const QgsVector3D c1( mHalfAxes[6], mHalfAxes[7], mHalfAxes[8] ), c0( -mHalfAxes[6], -mHalfAxes[7], -mHalfAxes[8] );
129 QVector<QgsVector3D> cor( 8 );
131 for (
int i = 0; i < 8; ++i, ++corData )
134 const QgsVector3D bb = ( ( i / 2 ) % 2 == 0 ? b1 : b0 );
144 QgsVector3D axis1( mHalfAxes[0], mHalfAxes[1], mHalfAxes[2] );
145 QgsVector3D axis2( mHalfAxes[3], mHalfAxes[4], mHalfAxes[5] );
146 QgsVector3D axis3( mHalfAxes[6], mHalfAxes[7], mHalfAxes[8] );
152 QgsVector3D axis1( mHalfAxes[0], mHalfAxes[1], mHalfAxes[2] );
153 QgsVector3D axis2( mHalfAxes[3], mHalfAxes[4], mHalfAxes[5] );
154 QgsVector3D axis3( mHalfAxes[6], mHalfAxes[7], mHalfAxes[8] );
162 Q_ASSERT(
c.count() == 8 );
163 for (
int i = 0; i < 8; ++i )
172 if ( v.x() < v0.
x() )
174 if ( v.y() < v0.
y() )
176 if ( v.z() < v0.
z() )
178 if ( v.x() > v1.x() )
180 if ( v.y() > v1.y() )
182 if ( v.z() > v1.z() )
185 return QgsBox3D( v0.
x(), v0.
y(), v0.
z(), v1.x(), v1.y(), v1.z() );
190 const double *ptr = transform.
constData();
191 const QgsMatrix4x4 mm( ptr[0], ptr[4], ptr[8], 0, ptr[1], ptr[5], ptr[9], 0, ptr[2], ptr[6], ptr[10], 0, 0, 0, 0, 1 );
200 QList<double>() << trCenter.
x() << trCenter.
y() << trCenter.
z(), QList<double>() << col1.
x() << col1.
y() << col1.
z() << col2.
x() << col2.
y() << col2.
z() << col3.
x() << col3.
y() << col3.
z()
210 const QgsVector3D thisHalfAxis[3] { { mHalfAxes[0], mHalfAxes[1], mHalfAxes[2] }, { mHalfAxes[3], mHalfAxes[4], mHalfAxes[5] }, { mHalfAxes[6], mHalfAxes[7], mHalfAxes[8] } };
213 [3] { { other.mHalfAxes[0], other.mHalfAxes[1], other.mHalfAxes[2] }, { other.mHalfAxes[3], other.mHalfAxes[4], other.mHalfAxes[5] }, { other.mHalfAxes[6], other.mHalfAxes[7], other.mHalfAxes[8] } };
215 for (
int a = 0; a < 3; ++a )
218 for (
int b = 0; b < 3; ++b )
234 const double penetration = ( ra + rb ) - tl;
235 if ( penetration <= 0 )
240 for (
int a = 0; a < 3; ++a )
252 const double penetration = ( ra + rb ) - tl;
253 if ( penetration <= 0 )
257 for (
int b = 0; b < 3; ++b )
269 const double penetration = ( ra + rb ) - tl;
270 if ( penetration <= 0 )
A 3-dimensional box composed of x, y, z coordinates.
QgsVector3D center() const
Returns the center of the box as a vector.
A simple 4x4 matrix implementation useful for transformation in 3D space.
QgsVector3D map(const QgsVector3D &vector) const
Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,...
const double * constData() const
Returns pointer to the matrix data (stored in column-major order).
const double * halfAxes() const
Returns the half axes matrix;.
QgsBox3D extent() const
Returns the overall bounding box of the object.
double longestSide() const
Returns size of the longest side of the box.
bool isNull() const
Returns true if the box is a null box.
QgsOrientedBox3D()
Constructor for a null oriented box.
bool intersects(const QgsOrientedBox3D &other) const
Returns true if the box intersects the other box.
QVector< QgsVector3D > corners() const
Returns an array of all corners as 3D vectors.
static QgsOrientedBox3D fromBox3D(const QgsBox3D &box)
Constructs an oriented box from an axis-aligned bounding box.
QList< double > halfAxesList() const
Returns the half axes matrix;.
QgsBox3D reprojectedExtent(const QgsCoordinateTransform &ct) const
Reprojects corners of this box using the given coordinate transform and returns axis-aligned box cont...
QgsVector3D center() const
Returns the vector to the center of the box.
QgsVector3D size() const
Returns size of sides of the box.
QgsOrientedBox3D transformed(const QgsMatrix4x4 &transform) const
Returns box transformed by a 4x4 matrix.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
void setZ(double z)
Sets Z coordinate.
bool isNull() const
Returns true if all three coordinates are zero.
static double dotProduct(const QgsVector3D &v1, const QgsVector3D &v2)
Returns the dot product of two vectors.
double x() const
Returns X coordinate.
void setX(double x)
Sets X coordinate.
void normalize()
Normalizes the current vector in place.
static QgsVector3D crossProduct(const QgsVector3D &v1, const QgsVector3D &v2)
Returns the cross product of two vectors.
void setY(double y)
Sets Y coordinate.
double length() const
Returns the length of the vector.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c