#include <qafVector3D.h>
This class overloads several operators to make evaluating formulae easier.
The multiplication operator (*
) can be used with a scalar argument (i.e., a float
value), or with another vector, in which case it stands for the dot product.
The modulus operator (%%
) represents a cross product.
Public Member Functions | |
Vector3D (float _x, float _y, float _z) | |
Vector3D (int _x, int _y, int _z) | |
Vector3D & | operator= (const Vector3D &v) |
float | length () const |
Returns the Euclidian norm of this vector. | |
Vector3D | unit () const |
Returns a copy of the vector, with length equal to 1. | |
float | dist (const Vector3D &that) const |
Returns the distance between the points denoted by this and that. | |
void | normalize () |
Resizes the vector so it will have length equal to 1. | |
Vector3D | project (const Vector3D &onto) const |
Returns the projection of this vector onto another. | |
Vector3D | reflect (const Vector3D &around) const |
Returns the reflection of this vector relative to around . | |
Vector3D | rotate (const Vector3D &axis, float angle) const |
Returns a rotated copy of this vector around axis . | |
Vector3D & | operator+= (const Vector3D &v) |
Vector3D & | operator-= (const Vector3D &v) |
Vector3D | operator+ (const Vector3D &v) const |
Vector3D | operator- (const Vector3D &v) const |
Vector3D | operator- () const |
Vector3D & | operator *= (float s) |
Vector3D | operator * (float s) const |
Vector3D & | operator/= (float s) |
Vector3D | operator/ (float s) const |
float | operator * (const Vector3D &v) const |
Returns the dot product of this vector and v . | |
Vector3D & | operator%= (const Vector3D &v) |
Returns the cross product of this vector and v . | |
Vector3D | operator% (const Vector3D &v) const |
Returns the cross product of this vector and v . | |
Public Attributes | |
float | x |
float | y |
float | z |
float qaf::Vector3D::length | ( | ) | const [inline] |
Returns the Euclidian norm of this vector.
Vector3D qaf::Vector3D::unit | ( | ) | const [inline] |
Returns a copy of the vector, with length equal to 1.
float qaf::Vector3D::dist | ( | const Vector3D & | that | ) | const [inline] |
Returns the distance between the points denoted by this and that.
void qaf::Vector3D::normalize | ( | ) | [inline] |
Resizes the vector so it will have length equal to 1.
Returns the projection of this vector onto another.
Returns the reflection of this vector relative to around
.
Returns a rotated copy of this vector around axis
.
float qaf::Vector3D::operator * | ( | const Vector3D & | v | ) | const [inline] |
Returns the dot product of this vector and v
.
Returns the cross product of this vector and v
.
Returns the cross product of this vector and v
.