Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QBox3D Class

The QBox3D class represents an axis-aligned box in 3D space. More...

 #include <QBox3D>

This class was introduced in Qt 4.8.

Public Functions

QBox3D()
QBox3D(const QVector3D & corner1, const QVector3D & corner2)
QVector3D center() const
bool contains(const QVector3D & point) const
bool contains(const QBox3D & box) const
void intersect(const QBox3D & box)
QBox3D intersected(const QBox3D & box) const
bool intersection(const QRay3D & ray, qreal * minimum_t, qreal * maximum_t) const
qreal intersection(const QRay3D & ray) const
bool intersects(const QRay3D & ray) const
bool intersects(const QBox3D & box) const
bool isFinite() const
bool isInfinite() const
bool isNull() const
QVector3D maximum() const
QVector3D minimum() const
void setExtents(const QVector3D & corner1, const QVector3D & corner2)
void setToInfinite()
void setToNull()
QVector3D size() const
void transform(const QMatrix4x4 & matrix)
QBox3D transformed(const QMatrix4x4 & matrix) const
void unite(const QVector3D & point)
void unite(const QBox3D & box)
QBox3D united(const QVector3D & point) const
QBox3D united(const QBox3D & box) const
bool operator!=(const QBox3D & box) const
bool operator==(const QBox3D & box) const

Related Non-Members

bool qFuzzyCompare(const QBox3D & box1, const QBox3D & box2)

Detailed Description

The QBox3D class represents an axis-aligned box in 3D space.

QBox3D can be used to represent the bounding box of objects in a 3D scene so that they can be easily culled if they are out of view.

The sides of the box are always aligned with the x, y, and z axes of the world co-ordinate system. Transforming a box with transformed() will result in the smallest axis-aligned bounding box that contains the transformed box.

Boxes may be null, finite, or infinite. A null box does not occupy any space and does not intersect with any other box. A finite box consists of a minimum() and maximum() extent in 3D space. An infinite box encompasses all points in 3D space.

The extents of a finite box are also included within the box. A box with minimum() and maximum() set to the same value contains a single point.

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.

Related Non-Members

bool qFuzzyCompare(const QBox3D & box1, const QBox3D & box2)

Returns true if box1 and box2 are almost equal; false otherwise.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web