Class for four dimensional vector. More...
#include <vmath.h>
Public Member Functions | |
Vector4 () | |
Creates and sets to (0,0,0,0). | |
Vector4 (T nx, T ny, T nz, T nw) | |
Creates and sets to (x,y,z,z). | |
Vector4 (const Vector4< T > &src) | |
Copy constructor. | |
template<class FromT > | |
Vector4 (const Vector4< FromT > &src) | |
Copy casting constructor. | |
Vector4< T > | operator= (const Vector4< T > &rhs) |
Copy operator. | |
template<class FromT > | |
Vector4< T > | operator= (const Vector4< FromT > &rhs) |
Copy casting operator. | |
T & | operator[] (int n) |
Array access operator. | |
const T & | operator[] (int n) const |
Array access operator. | |
Vector4< T > | operator+ (const Vector4< T > &rhs) const |
Addition operator. | |
Vector4< T > | operator- (const Vector4< T > &rhs) const |
Subtraction operator. | |
Vector4< T > | operator* (const Vector4< T > rhs) const |
Multiplication operator. | |
Vector4< T > | operator/ (const Vector4< T > &rhs) const |
Division operator. | |
Vector4< T > & | operator+= (const Vector4< T > &rhs) |
Addition operator. | |
Vector4< T > & | operator-= (const Vector4< T > &rhs) |
Subtraction operator. | |
Vector4< T > & | operator*= (const Vector4< T > &rhs) |
Multiplication operator. | |
Vector4< T > & | operator/= (const Vector4< T > &rhs) |
Division operator. | |
bool | operator== (const Vector4< T > &rhs) const |
Equality test operator. | |
bool | operator!= (const Vector4< T > &rhs) const |
Inequality test operator. | |
Vector4< T > | operator- () const |
Unary negate operator. | |
Vector4< T > | operator+ (T rhs) const |
Addition operator. | |
Vector4< T > | operator- (T rhs) const |
Subtraction operator. | |
Vector4< T > | operator* (T rhs) const |
Multiplication operator. | |
Vector4< T > | operator/ (T rhs) const |
Division operator. | |
Vector4< T > & | operator+= (T rhs) |
Addition operator. | |
Vector4< T > & | operator-= (T rhs) |
Subtraction operator. | |
Vector4< T > & | operator*= (T rhs) |
Multiplication operator. | |
Vector4< T > & | operator/= (T rhs) |
Division operator. | |
T | length () const |
Get length of vector. | |
void | normalize () |
Normalize vector. | |
T | lengthSq () const |
Return square of length. | |
Vector4< T > | lerp (T fact, const Vector4< T > &r) const |
Linear interpolation of two vectors. | |
operator T * () | |
Conversion to pointer operator. | |
operator const T * () const | |
Conversion to pointer operator. | |
std::string | toString () const |
Gets string representation. | |
Public Attributes | |
union { | |
T r | |
First element of vector, alias for R-coordinate. | |
T x | |
}; | |
union { | |
T g | |
Second element of vector, alias for G-coordinate. | |
T y | |
Second element of vector, alias for Y-coordinate. | |
}; | |
union { | |
T b | |
Third element of vector, alias for B-coordinate. | |
T z | |
Third element of vector, alias for Z-coordinate. | |
}; | |
union { | |
T a | |
Fourth element of vector, alias for A-coordinate. | |
T w | |
First element of vector, alias for W-coordinate. | |
}; | |
Friends | |
std::ostream & | operator<< (std::ostream &lhs, const Vector4< T > &rhs) |
Output to stream operator. |
Class for four dimensional vector.
There are four ways of accessing vector components. Let's have Vector4f v
, you can either:
v.x = v.y = v.z = v.w = 1;
v.s = v.t = v.u = v.v = 1;
v.r = v.g = v.b = v.a = 1;
v[0] = v[1] = v[2] = v[3] = 1;
Creates and sets to (x,y,z,z).
nx | initial x-coordinate value (R) | |
ny | initial y-coordinate value (G) | |
nz | initial z-coordinate value (B) | |
nw | initial w-coordinate value (Alpha) |
Copy constructor.
src | Source of data for new created Vector4 instance. |
Vector4< T >::Vector4 | ( | const Vector4< FromT > & | src | ) | [inline] |
Copy casting constructor.
src | Source of data for new created Vector4 instance. |
T Vector4< T >::length | ( | ) | const [inline] |
Get length of vector.
T Vector4< T >::lengthSq | ( | ) | const [inline] |
Linear interpolation of two vectors.
fact | Factor of interpolation. For translation from position of this vector to vector r, values of factor goes from 0.0 to 1.0. | |
r | Second Vector for interpolation |
void Vector4< T >::normalize | ( | ) | [inline] |
Normalize vector.
Vector4< T >::operator const T * | ( | ) | const [inline] |
Conversion to pointer operator.
Vector4< T >::operator T * | ( | ) | [inline] |
Conversion to pointer operator.
Inequality test operator.
rhs | Right hand side argument of binary operator. |
Multiplication operator.
rhs | Right hand side argument of binary operator. |
Multiplication operator.
rhs | Right hand side argument of binary operator. |
Multiplication operator.
rhs | Right hand side argument of binary operator. |
Multiplication operator.
rhs | Right hand side argument of binary operator. |
Addition operator.
rhs | Right hand side argument of binary operator. |
Addition operator.
rhs | Right hand side argument of binary operator. |
Addition operator.
rhs | Right hand side argument of binary operator. |
Addition operator.
rhs | Right hand side argument of binary operator. |
Subtraction operator.
rhs | Right hand side argument of binary operator. |
Subtraction operator.
rhs | Right hand side argument of binary operator. |
Unary negate operator.
Subtraction operator.
rhs | Right hand side argument of binary operator. |
Subtraction operator.
rhs | Right hand side argument of binary operator. |
Division operator.
rhs | Right hand side argument of binary operator. |
Division operator.
rhs | Right hand side argument of binary operator. |
Division operator.
rhs | Right hand side argument of binary operator. |
Division operator.
rhs | Right hand side argument of binary operator. |
Vector4<T> Vector4< T >::operator= | ( | const Vector4< FromT > & | rhs | ) | [inline] |
Copy casting operator.
rhs | Right hand side argument of binary operator. |
Copy operator.
rhs | Right hand side argument of binary operator. |
Equality test operator.
rhs | Right hand side argument of binary operator. |
T& Vector4< T >::operator[] | ( | int | n | ) | [inline] |
Array access operator.
n | Array index |
const T& Vector4< T >::operator[] | ( | int | n | ) | const [inline] |
Array access operator.
n | Array index |
std::string Vector4< T >::toString | ( | ) | const [inline] |
Gets string representation.
std::ostream& operator<< | ( | std::ostream & | lhs, | |
const Vector4< T > & | rhs | |||
) | [friend] |
Output to stream operator.
lhs | Left hand side argument of operator (commonly ostream instance). | |
rhs | Right hand side argument of operator. |
union { ... } |
union { ... } |
union { ... } |
union { ... } |
Fourth element of vector, alias for A-coordinate.
For color notation. This represnt aplha chanell
Third element of vector, alias for B-coordinate.
For color notation.
Second element of vector, alias for G-coordinate.
For color notation.
First element of vector, alias for R-coordinate.
For color notation. First element of vector, alias for X-coordinate.
First element of vector, alias for W-coordinate.