A 4D vector. More...
#include <vec4.h>
Public Member Functions | |
vec4 () | |
Creates a new, uninitialized vector. | |
vec4 (type xi, type yi, type zi, type wi) | |
Creates a new vector with the given coordinates. | |
vec4 (const type v[4]) | |
Creates a new vector with the given coordinates. | |
vec4 (const vec4 &v) | |
Creates a new vector as a copy of the given vector. | |
vec4 (const vec3< type > &v) | |
Creates a new vector as a copy of the given vector. | |
vec4 (const vec3< type > &v, const type wi) | |
Creates a new vector as an extension of a vec3. | |
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. | |
vec4 | operator= (const vec4 &v) |
Assigns the given vector to this vector. | |
bool | operator== (const vec4 &v) const |
Returns true if this vector is equal to the given vector. | |
bool | operator!= (const vec4 &v) const |
Returns true if this vector is different from the given vector. | |
vec4 | operator+ (const vec4 &v) const |
Returns the sum of this vector and of the given vector. | |
vec4 | operator- (const vec4 &v) const |
Returns the difference of this vector and of the given vector. | |
vec4 | operator* (const vec4 &v) const |
Returns the product of this vector and of the given vector. | |
vec4 | operator* (const type scalar) const |
Returns the product of this vector and of the given scalar. | |
vec4 | operator/ (const vec4 &v) const |
Returns the division of this vector and of the given vector. | |
vec4 | operator/ (const type scalar) const |
Returns the division of this vector and of the given scalar. | |
vec4 | operator- () const |
Returns the opposite of this vector. | |
vec4 & | operator+= (const vec4 &v) |
Adds the given vector to this vector. | |
vec4 & | operator-= (const vec4 &v) |
Substracts the given vector from this vector. | |
vec4 & | operator*= (const type scalar) |
Multiplies this vector by the given scalar. | |
vec4 & | operator/= (const type scalar) |
Divides this vector by the given scalar. | |
bool | operator< (const vec4 &v) const |
Compare first element, then second if equal, then third if equal, then fourth if equal. | |
type | dotproduct (const vec3< type > &v) const |
Returns the dot product of this vector and of the given vector. | |
type | dotproduct (const vec4 &v) const |
Returns the dot product of this vector and of the given vector. | |
vec3< type > | xyz () const |
Returns the 3D vector defined by (x,y,z). | |
vec2< type > | xy () const |
Returns the 2D vector defined by (x,y). | |
template<class t > | |
vec4< t > | cast () const |
Casts this vector to another base type. | |
Public Attributes | |
type | x |
x coordinate. | |
type | y |
x coordinate. | |
type | z |
z coordinate. | |
type | w |
w coordinate. | |
Static Public Attributes | |
static const vec4 | ZERO |
The null vector (0,0,0,0). | |
static const vec4 | UNIT_X |
The unit x vector (1,0,0,0). | |
static const vec4 | UNIT_Y |
The unit y vector (0,1,0,0). | |
static const vec4 | UNIT_Z |
The unit z vector (0,0,1,0). | |
static const vec4 | UNIT_W |
The unit w vector (0,0,0,1). |
A 4D 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.
Creates a new vector as a copy of the given vector.
The fourth coordinate is initialized to 1.
Creates a new vector as an extension of a vec3.
Casts this vector to another base type.
type ork::vec4< type >::dotproduct | ( | const vec4< type > & | v | ) | const [inline] |
Returns the dot product of this vector and of the given vector.
type ork::vec4< type >::dotproduct | ( | const vec3< type > & | v | ) | const [inline] |
Returns the dot product of this vector and of the given vector.
The given vector is considered as a 4D vector with w = 1.
bool ork::vec4< type >::operator!= | ( | const vec4< type > & | v | ) | const [inline] |
Returns true if this vector is different from the given vector.
vec4< type > ork::vec4< type >::operator* | ( | const type | scalar | ) | const [inline] |
Returns the product of this vector and of the given scalar.
vec4< type > ork::vec4< type >::operator* | ( | const vec4< 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.
vec4< type > ork::vec4< type >::operator+ | ( | const vec4< type > & | v | ) | const [inline] |
Returns the sum of this vector and of the given vector.
vec4< type > & ork::vec4< type >::operator+= | ( | const vec4< type > & | v | ) | [inline] |
Adds the given vector to this vector.
Returns the opposite of this vector.
vec4< type > ork::vec4< type >::operator- | ( | const vec4< type > & | v | ) | const [inline] |
Returns the difference of this vector and of the given vector.
vec4< type > & ork::vec4< type >::operator-= | ( | const vec4< type > & | v | ) | [inline] |
Substracts the given vector from this vector.
vec4< type > ork::vec4< type >::operator/ | ( | const type | scalar | ) | const [inline] |
Returns the division of this vector and of the given scalar.
vec4< type > ork::vec4< type >::operator/ | ( | const vec4< 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::vec4< type >::operator< | ( | const vec4< type > & | v | ) | const [inline] |
Compare first element, then second if equal, then third if equal, then fourth if equal.
vec4< type > ork::vec4< type >::operator= | ( | const vec4< type > & | v | ) | [inline] |
Assigns the given vector to this vector.
bool ork::vec4< type >::operator== | ( | const vec4< type > & | v | ) | const [inline] |
Returns true if this vector is equal to the given vector.
type & ork::vec4< type >::operator[] | ( | const int | i | ) | [inline] |
Returns the coordinate of this vector whose index is given.
type ork::vec4< type >::operator[] | ( | const int | i | ) | const [inline] |
Returns the coordinate of this vector whose index is given.
Returns the 2D vector defined by (x,y).
Returns the 3D vector defined by (x,y,z).
The unit w vector (0,0,0,1).
The unit x vector (1,0,0,0).
The unit y vector (0,1,0,0).
The unit z vector (0,0,1,0).