A 3D vector. More...
#include <vec3.h>
Public Member Functions | |
vec3 () | |
Creates a new, uninitialized vector. | |
vec3 (type xi, type yi, type zi) | |
Creates a new vector with the given coordinates. | |
vec3 (const type v[3]) | |
Creates a new vector with the given coordinates. | |
vec3 (const vec3 &v) | |
Creates a new vector as a copy of the given vector. | |
type | operator[] (const int i) const |
Returns the coordinate of this vector whose index is given. | |
type & | operator[] (const int i) |
Returns the coordinate of this vector whose index is given. | |
void | operator= (const vec3 &v) |
Assigns the given vector to this vector. | |
bool | operator== (const vec3 &v) const |
Returns true if this vector is equal to the given vector. | |
bool | operator!= (const vec3 &v) const |
Returns true if this vector is different from the given vector. | |
vec3 | operator+ (const vec3 &v) const |
Returns the sum of this vector and of the given vector. | |
vec3 | operator- (const vec3 &v) const |
Returns the difference of this vector and of the given vector. | |
vec3 | operator* (const vec3 &v) const |
Returns the product of this vector and of the given vector. | |
vec3 | operator* (const type scalar) const |
Returns the product of this vector and of the given scalar. | |
vec3 | operator/ (const vec3 &v) const |
Returns the division of this vector and of the given vector. | |
vec3 | operator/ (const type scalar) const |
Returns the division of this vector and of the given scalar. | |
vec3 | operator- () const |
Returns the opposite of this vector. | |
vec3 & | operator+= (const vec3 &v) |
Adds the given vector to this vector. | |
vec3 & | operator-= (const vec3 &v) |
Substracts the given vector from this vector. | |
vec3 & | operator*= (const type scalar) |
Multiplies this vector by the given scalar. | |
vec3 & | operator/= (const type scalar) |
Divides this vector by the given scalar. | |
bool | operator< (const vec3 &v) const |
Compare first element, then second if equal, then third if equal. | |
type | length () const |
Returns the length of this vector. | |
type | squaredLength () const |
Returns the squared length of this vector. | |
type | dotproduct (const vec3 &v) const |
Returns the dot product of this vector and of the given vector. | |
vec3 | normalize () const |
Returns this vector normalized to unit length. | |
vec3 | normalize (type l) const |
Returns this vector normalized to the given length. | |
vec3 | normalize (type *previousLength) const |
Returns this vector normalized to unit length. | |
vec3 | normalize (type l, type *previousLength) |
Returns this vector normalized to the given length. | |
vec3 | crossProduct (const vec3 &v) const |
Returns he cross product of this vector and of the given vector. | |
vec2< type > | xy () const |
Returns the 2D vector defined by (x,y). | |
template<class t > | |
vec3< t > | cast () const |
Casts this vector to another base type. | |
Public Attributes | |
type | x |
x coordinate. | |
type | y |
x coordinate. | |
type | z |
z coordinate. | |
Static Public Attributes | |
static const vec3 | ZERO |
The null vector (0,0,0). | |
static const vec3 | UNIT_X |
The unit x vector (1,0,0). | |
static const vec3 | UNIT_Y |
The unit y vector (0,1,0). | |
static const vec3 | UNIT_Z |
The unit z vector (0,0,1). |
A 3D vector.
Creates a new vector with the given coordinates.
Creates a new vector with the given coordinates.
Creates a new vector as a copy of the given vector.
Casts this vector to another base type.
vec3< type > ork::vec3< type >::crossProduct | ( | const vec3< type > & | v | ) | const [inline] |
Returns he cross product of this vector and of the given vector.
type ork::vec3< type >::dotproduct | ( | const vec3< type > & | v | ) | const [inline] |
Returns the dot product of this vector and of the given vector.
type ork::vec3< type >::length | ( | ) | const [inline] |
Returns the length of this vector.
vec3< type > ork::vec3< type >::normalize | ( | type | l, | |
type * | previousLength | |||
) | [inline] |
Returns this vector normalized to the given length.
Returns also its initial length.
vec3< type > ork::vec3< type >::normalize | ( | type * | previousLength | ) | const [inline] |
Returns this vector normalized to unit length.
Returns also its initial length.
Returns this vector normalized to the given length.
Returns this vector normalized to unit length.
bool ork::vec3< type >::operator!= | ( | const vec3< type > & | v | ) | const [inline] |
Returns true if this vector is different from the given vector.
vec3< type > ork::vec3< type >::operator* | ( | const type | scalar | ) | const [inline] |
Returns the product of this vector and of the given scalar.
vec3< type > ork::vec3< type >::operator* | ( | const vec3< type > & | v | ) | const [inline] |
Returns the product of this vector and of the given vector.
The product is done component by component.
Multiplies this vector by the given scalar.
vec3< type > ork::vec3< type >::operator+ | ( | const vec3< type > & | v | ) | const [inline] |
Returns the sum of this vector and of the given vector.
vec3< type > & ork::vec3< type >::operator+= | ( | const vec3< type > & | v | ) | [inline] |
Adds the given vector to this vector.
Returns the opposite of this vector.
vec3< type > ork::vec3< type >::operator- | ( | const vec3< type > & | v | ) | const [inline] |
Returns the difference of this vector and of the given vector.
vec3< type > & ork::vec3< type >::operator-= | ( | const vec3< type > & | v | ) | [inline] |
Substracts the given vector from this vector.
vec3< type > ork::vec3< type >::operator/ | ( | const type | scalar | ) | const [inline] |
Returns the division of this vector and of the given scalar.
vec3< type > ork::vec3< type >::operator/ | ( | const vec3< type > & | v | ) | const [inline] |
Returns the division of this vector and of the given vector.
The division is done component by component.
Divides this vector by the given scalar.
bool ork::vec3< type >::operator< | ( | const vec3< type > & | v | ) | const [inline] |
Compare first element, then second if equal, then third if equal.
Assigns the given vector to this vector.
bool ork::vec3< type >::operator== | ( | const vec3< type > & | v | ) | const [inline] |
Returns true if this vector is equal to the given vector.
type & ork::vec3< type >::operator[] | ( | const int | i | ) | [inline] |
Returns the coordinate of this vector whose index is given.
type ork::vec3< type >::operator[] | ( | const int | i | ) | const [inline] |
Returns the coordinate of this vector whose index is given.
type ork::vec3< type >::squaredLength | ( | ) | const [inline] |
Returns the squared length of this vector.
Returns the 2D vector defined by (x,y).
The unit x vector (1,0,0).
The unit y vector (0,1,0).
The unit z vector (0,0,1).