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  · 

QSphere3D Class

The QSphere3D class represents a mathematical sphere in 3D space. More...

 #include <QSphere3D>

This class was introduced in Qt 4.8.

Public Functions

QSphere3D()
QSphere3D(const QVector3D & center, qreal radius)
QVector3D center() const
bool contains(const QVector3D & point) 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 QSphere3D & sphere) const
bool intersects(const QBox3D & box) const
bool intersects(const QPlane3D & plane) const
qreal radius() const
void setCenter(const QVector3D & center)
void setRadius(qreal radius)
void transform(const QMatrix4x4 & matrix)
QSphere3D transformed(const QMatrix4x4 & matrix) const
bool operator!=(const QSphere3D & sphere) const
bool operator==(const QSphere3D & sphere) const

Related Non-Members

bool qFuzzyCompare(const QSphere3D & sphere1, const QSphere3D & sphere2)

Detailed Description

The QSphere3D class represents a mathematical sphere in 3D space.

QSphere3D can be used to represent the bounding regions of objects in a 3D scene so that they can be easily culled if they are out of view. It can also be used to assist with collision testing.

See also QBox3D.

Member Function Documentation

QSphere3D::QSphere3D()

Constructs a default sphere with a center() of (0, 0, 0) and radius() of 1.

QSphere3D::QSphere3D(const QVector3D & center, qreal radius)

Constructs a sphere with the specified center and radius.

QVector3D QSphere3D::center() const

Returns the center of this sphere.

See also setCenter() and radius().

bool QSphere3D::contains(const QVector3D & point) const

Returns true if point is contained within the bounds of this sphere; false otherwise.

bool QSphere3D::intersection(const QRay3D & ray, qreal * minimum_t, qreal * maximum_t) const

Finds the minimum_t and maximum_t values where ray intersects this sphere. 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 ray touches the surface of the sphere at a single point. 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 (sphere.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 QSphere3D::intersection(const QRay3D & ray) const

Returns the t value at which ray first intersects the surface of this sphere, or not-a-number if there is no intersection.

When the ray intersects this sphere, 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 = sphere.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 sphere - 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 sphere, 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 sphere, and the direction points away from the sphere, then there will be no intersection.

When the ray does not intersect the sphere in the positive direction, then the return value is not-a-number.

See also intersects() and QRay3D::point().

bool QSphere3D::intersects(const QRay3D & ray) const

Returns true if this sphere intersects ray; false otherwise.

See also intersection().

bool QSphere3D::intersects(const QSphere3D & sphere) const

Returns true if this sphere intersects sphere; false otherwise.

See also contains().

bool QSphere3D::intersects(const QBox3D & box) const

Returns true if this sphere intersects box; false otherwise.

bool QSphere3D::intersects(const QPlane3D & plane) const

Returns true if this sphere intersects plane; false otherwise.

qreal QSphere3D::radius() const

Returns the radius of this sphere.

See also setRadius() and center().

void QSphere3D::setCenter(const QVector3D & center)

Sets the center of this sphere.

See also center() and setRadius().

void QSphere3D::setRadius(qreal radius)

Sets the radius of this sphere.

See also radius() and setCenter().

void QSphere3D::transform(const QMatrix4x4 & matrix)

Transforms this sphere's center() and radius() according to matrix.

It is assumed that matrix contains a uniform scale factor in the x, y, and z directions. Otherwise the radius() in the result is undefined.

See also transformed().

QSphere3D QSphere3D::transformed(const QMatrix4x4 & matrix) const

Returns the result of transforming this sphere's center() and radius() according to matrix.

It is assumed that matrix contains a uniform scale factor in the x, y, and z directions. Otherwise the radius() in the result is undefined.

See also transform().

bool QSphere3D::operator!=(const QSphere3D & sphere) const

Returns true if this sphere is not the same as sphere; false otherwise.

See also operator==().

bool QSphere3D::operator==(const QSphere3D & sphere) const

Returns true if this sphere is the same as sphere; false otherwise.

See also operator!=().

Related Non-Members

bool qFuzzyCompare(const QSphere3D & sphere1, const QSphere3D & sphere2)

Returns true if sphere1 and sphere2 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