Member Function Documentation
QBox3D::QBox3D()
Constructs a null box in 3D space.
See also isNull().
QBox3D::QBox3D(const QVector3D & corner1, const QVector3D & corner2)
Constructs a finite box in 3D space from corner1 to corner2. The minimum() and maximum() co-ordinates of the new box are set to the minimum and maximum x, y, and z values from corner1 and corner2. The corner1 and corner2 values can be any two opposite corners that define the box.
See also isFinite(), minimum(), and maximum().
QVector3D QBox3D::center() const
Returns the finite center of this box. If this box is null or infinite, the returned value will be zero.
See also size(), isNull(), and isInfinite().
bool QBox3D::contains(const QVector3D & point) const
Returns true if this box contains point; false otherwise. Null boxes do not contain any points and infinite boxes contain all points.
Containment is not a strict test: the point is contained if it lies on one of the faces of the box.
See also intersects().
bool QBox3D::contains(const QBox3D & box) const
Returns true if this box completely contains box. If this box is null, then it will not contain box. If this box is infinite, and box is not null, then box will be contained within this box. If box is infinite, then this box must also be infinite to contain it.
See also intersects().
void QBox3D::intersect(const QBox3D & box)
Intersects this box with box.
See also intersected(), intersects(), and unite().
QBox3D QBox3D::intersected(const QBox3D & box) const
Returns a new box which is the intersection of this box with box.
See also intersect(), intersects(), and united().
bool QBox3D::intersection(const QRay3D & ray, qreal * minimum_t, qreal * maximum_t) const
Finds the minimum_t and maximum_t values where ray intersects this box. Returns true if intersections were found; or false if there is no intersection.
If minimum_t and maximum_t are set to the same value, then the intersection is at a corner or the volume of the box is zero. If the t values are negative, then the intersection occurs before the ray's origin point in the reverse direction of the ray.
The minimum_t and maximum_t values can be passed to QRay3D::point() to determine the actual intersection points, as shown in the following example:
qreal minimum_t, maximum_t;
if (box.intersection(ray, &minimum_t, &maximum_t)) {
qDebug() << "intersections at"
<< ray.point(minimum_t) << "and"
<< ray.point(maximum_t);
}
See also intersects() and QRay3D::point().
qreal QBox3D::intersection(const QRay3D & ray) const
Returns the t value at which ray first intersects the sides of this box, or not-a-number if there is no intersection.
When the ray intersects this box, the return value is a parametric value that can be passed to QRay3D::point() to determine the actual intersection point, as shown in the following example:
qreal t = box.intersection(ray);
QVector3D pt;
if (qIsNaN(t)) {
qWarning("no intersection occurred");
else
pt = ray.point(t);
The ray might intersect at two points - as the ray passes through the box - one on the near side, one on the far side; where near and far are relative to the origin point of the ray. This function only returns the near intersection point.
Only positive values on the ray are considered. This means that if the origin point of the ray is inside the box, there is only one solution, not two. To get the other solution, simply change the sign of the ray's direction vector. If the origin point of the ray is outside the box, and the direction points away from the box, then there will be no intersection.
When the ray does not intersect the box in the positive direction, or the box is not finite, then the return value is not-a-number.
See also intersects() and QRay3D::point().
bool QBox3D::intersects(const QRay3D & ray) const
Returns true if ray intersects this box; false otherwise.
See also intersection().
bool QBox3D::intersects(const QBox3D & box) const
Returns true if box intersects this box; false otherwise.
See also intersect(), intersected(), and contains().
bool QBox3D::isFinite() const
Returns true if this box is finite in size; false otherwise.
See also isNull(), isInfinite(), and setExtents().
bool QBox3D::isInfinite() const
Returns true if this box is infinite in size; false otherwise.
See also isNull(), isFinite(), and setToInfinite().
bool QBox3D::isNull() const
Returns true if this box is null; false otherwise.
See also isFinite(), isInfinite(), and setToNull().
QVector3D QBox3D::maximum() const
Returns the maximum corner of this box.
See also minimum() and setExtents().
QVector3D QBox3D::minimum() const
Returns the minimum corner of this box.
See also maximum() and setExtents().
void QBox3D::setExtents(const QVector3D & corner1, const QVector3D & corner2)
Sets the extents of this box to a finite region from corner1 to corner2. The minimum() and maximum() co-ordinates of the box are set to the minimum and maximum x, y, and z values from corner1 and corner2. The corner1 and corner2 values can be any two opposite corners that define the box.
See also minimum() and maximum().
void QBox3D::setToInfinite()
Sets this box to be infinite in size.
See also isInfinite().
void QBox3D::setToNull()
Sets this box to null.
See also isNull().
QVector3D QBox3D::size() const
Returns the finite size of this box. If this box is null or infinite, the returned value will be zero.
See also center(), isNull(), and isInfinite().
void QBox3D::transform(const QMatrix4x4 & matrix)
Transforms this box according to matrix. Each of the 8 box corners are transformed and then a new box that encompasses all of the transformed corner values is created.
See also transformed().
QBox3D QBox3D::transformed(const QMatrix4x4 & matrix) const
Returns this box transformed by matrix. Each of the 8 box corners are transformed and then a new box that encompasses all of the transformed corner values is returned.
See also transform().
void QBox3D::unite(const QVector3D & point)
Unites this box with point by expanding it to encompass point. If point is already contained within this box, then this box will be unchanged.
See also united() and intersect().
void QBox3D::unite(const QBox3D & box)
Unites this box with box by expanding this box to encompass the region defined by box. If box is already contained within this box, then this box will be unchanged.
See also united() and intersect().
QBox3D QBox3D::united(const QVector3D & point) const
Returns a new box which unites this box with point. The returned value will be the smallest box that contains both this box and point.
See also unite() and intersected().
QBox3D QBox3D::united(const QBox3D & box) const
Returns a new box which unites this box with box. The returned value will be the smallest box that contains both this box and box.
See also unite() and intersected().
bool QBox3D::operator!=(const QBox3D & box) const
Returns true if this box is not identical to box.
bool QBox3D::operator==(const QBox3D & box) const
Returns true if this box is identical to box.