v0.1.8
|
A four dimensional 32 bit floating point vector. More...
#include <Vector4.hpp>
Public Member Functions | |
Vector4T () | |
Initializes to (0, 0, 0, 0). | |
Vector4T (const Vector4T ©) | |
Copies a vector into this vector. More... | |
Vector4T (Type value) | |
Initializes all components to a given value. More... | |
Vector4T (Type x, Type y, Type z, Type w) | |
Initializes the vector with individual component values. More... | |
Vector4T & | operator= (const Vector4T &operand) |
Assigns another vector into this vector. More... | |
Type & | operator[] (UInt32 index) |
Accesses an individual component in this vector. More... | |
Type | operator[] (UInt32 index) const |
Accesses an individual (constant) component in this vector. More... | |
Vector4T | operator- () const |
Gets the inverse of the vector. More... | |
bool | operator== (const Vector4T &operand) const |
Checks if two vectors are exactly equal. More... | |
bool | operator!= (const Vector4T &operand) const |
Checks if two vectors are not exactly equal. More... | |
Vector4T | operator+ (const Vector4T &operand) const |
Performs component-based addition on two vectors. More... | |
Vector4T & | operator+= (const Vector4T &operand) |
Adds the individual components of another vector to this vector's components. More... | |
Vector4T | operator- (const Vector4T &operand) const |
Performs component-based subtraction on two vectors. More... | |
Vector4T & | operator-= (const Vector4T &operand) |
Subtracts the individual components of another vector from this vector's components. More... | |
Vector4T | operator* (Type operand) const |
Performs component-based multiplication on two vectors. More... | |
Vector4T | operator* (const MatrixT< Type > &operand) const |
Vector4T & | operator*= (Type operand) |
Multiplies the individual components of another vector onto this vector's components. More... | |
Vector4T & | operator*= (const MatrixT< Type > &operand) |
Vector4T | operator/ (Type operand) const |
Performs component-based division on two vectors. More... | |
Vector4T & | operator/= (Type operand) |
Divides the individual components of another vector onto this vector's components. More... | |
template<typename OtherType > | |
operator Vector4T< OtherType > () | |
Type & | At (UInt32 index) |
Accesses an individual component in this vector. More... | |
Type | At (UInt32 index) const |
Accesses an individual (constant) component in this vector. More... | |
void | Set (Type value) |
Sets all components to a given value. More... | |
void | Set (Type x, Type y, Type z, Type w) |
Sets all components to the given values. More... | |
void | Clear () |
Clears the vector to (0, 0, 0, 0). | |
Vector2T< Type > | Swizzle (UInt32 x, UInt32 y) const |
Performs a two dimensional swizzle. More... | |
Vector3T< Type > | Swizzle (UInt32 x, UInt32 y, UInt32 z) const |
Performs a three dimensional swizzle. More... | |
Vector4T< Type > | Swizzle (UInt32 x, UInt32 y, UInt32 z, UInt32 w) const |
Performs a four dimensional swizzle. More... | |
void | Normalize () |
Normalizes the vector resulting in a length of 1. More... | |
Boolean | IsNormalized (Type epsilon=0.00001f) const |
Checks if the vector is normalizes within a given epsilon. More... | |
Type | GetMagnitude () const |
Gets the magnitude of the vector. More... | |
Type | GetSquaredMagnitude () const |
Gets the squared magnitude of the vector. More... | |
Type | GetManhattanMagnitude () const |
Gets the manhattan magnitude of the vector. More... | |
Type | GetDistance (const Vector4T &other) const |
Gets the distance between two vectors. More... | |
Type | GetSquaredDistance (const Vector4T &other) const |
Gets the squared distance between two vectors. More... | |
Type | GetManhattanDistance (const Vector4T &other) const |
Gets the manhattan distance between two vectors. More... | |
void | Floor () |
Rounds down each component to the nearest whole number. | |
void | Round () |
Rounds each component to the nearest whole number. | |
void | Ceil () |
Rounds up each component to the nearest whole number. | |
Vector4T | Floored () const |
Returns a vector with each component rounded down. More... | |
Vector4T | Rounded () const |
Returns a vector with each component rounded. More... | |
Vector4T | Ceiled () const |
Returns a vector with each component rounded up. More... | |
Type | SumComponents () const |
Gets the sum of the elements. More... | |
Type | MultiplyComponents () const |
Gets the product of the elements. More... | |
Type | IsNaN () const |
Static Public Member Functions | |
static Type | DotProduct (const Vector4T &valueA, const Vector4T &valueB) |
static Vector4T | Normalized (const Vector4T &value) |
static Type | Distance (const Vector4T &vectorA, const Vector4T &vectorB) |
static Type | DistanceSquared (const Vector4T &valueA, const Vector4T &vectorB) |
static Type | DistanceManhattan (const Vector4T &valueA, const Vector4T &vectorB) |
static Vector4T | Lerp (const Vector4T &from, const Vector4T &to, Type t) |
Performs linear interpolation on a vector4. | |
Public Attributes | |
Type | x |
The x component. | |
Type | y |
The y component. | |
Type | z |
The z component. | |
Type | w |
The w component. | |
Static Public Attributes | |
static const Vector4T | zero |
Zero vector, defined as (0, 0, 0, 0). | |
static const Vector4T | one |
One vector, defined as (1, 1, 1, 1). | |
static const Vector4T | unitX |
Unit X vector, defined as (1, 0, 0, 0). | |
static const Vector4T | unitY |
Unit Y vector, defined as (0, 1, 0, 0). | |
static const Vector4T | unitZ |
Unit Y vector, defined as (0, 0, 1, 0). | |
static const Vector4T | unitW |
Unit Y vector, defined as (0, 0, 0, 1). | |
static const Vector4T | nan |
NaN vector, defined as (NaN, NaN, NaN, NaN). | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Vector4T< Type > &vector) |
An operator to output this vector on an output stream. | |
A four dimensional 32 bit floating point vector.
|
inline |
Copies a vector into this vector.
copy | The vector to copy. |
|
inline |
Initializes all components to a given value.
value | The value for each component. |
|
inline |
Initializes the vector with individual component values.
x | The x component. |
y | The y component. |
z | The z component. |
w | The w component. |
|
inline |
Accesses an individual component in this vector.
index | The component index, so 0 for x, 1 for y, 2 for z, and 3 for w. |
|
inline |
Accesses an individual (constant) component in this vector.
index | The component index, so 0 for x, 1 for y, 2 for z, and 3 for w. |
|
inline |
Returns a vector with each component rounded up.
|
inline |
Returns a vector with each component rounded down.
|
inline |
Gets the distance between two vectors.
The distance between two vectors is defined as the magnitude of one vector subtracted by another. In other words: GetMagnitude(Vec1 - Vec2). Because of this the same notes in GetMagnitude apply to this method.
other | The other vector. |
|
inline |
Gets the magnitude of the vector.
Faster implementations of this method exist but are less accurate. For more information, see GetSquaredMagnitude and GetManhattanMagnitude.
|
inline |
Gets the manhattan distance between two vectors.
other | The other vector. |
|
inline |
Gets the manhattan magnitude of the vector.
The Manhattan magnitude is even faster than the GetMagnitudeSquared alternative, but far less accurate. The squared magnitude cannot be used to determine if one magnitude is larger than another, nor can it be used to compare magnitudes. The purpose of the Manhattan magnitude is mostly used as a guess to speed up algorithms that may use it as a heuristic.
|
inline |
Gets the squared distance between two vectors.
other | The other vector. |
|
inline |
Gets the squared magnitude of the vector.
The squared magnitude is a less accurate, but more quickly calculated alternative to the GetMagnitude method. A squared magnitude can be used to measure if one magnitude is larger than another, but cannot be used to accurately determine differences between magnitudes.
|
inline |
|
inline |
Checks if the vector is normalizes within a given epsilon.
|
inline |
Gets the product of the elements.
|
inline |
Normalizes the vector resulting in a length of 1.
|
inline |
Checks if two vectors are not exactly equal.
Due to floating point imprecision, vectors are rarely ever exactly equal. Use with care.
operand | The other vector. |
|
inline |
Performs component-based multiplication on two vectors.
operand | A scalar value. |
|
inline |
Multiplies the individual components of another vector onto this vector's components.
operand | A scalar value. |
|
inline |
Performs component-based addition on two vectors.
operand | The other vector. |
|
inline |
Adds the individual components of another vector to this vector's components.
operand | The other operand. |
|
inline |
Gets the inverse of the vector.
The inverse is defined as (-x, -y, -z, -w) of the original vector.
|
inline |
Performs component-based subtraction on two vectors.
operand | The other vector. |
|
inline |
Subtracts the individual components of another vector from this vector's components.
operand | The other operand. |
|
inline |
Performs component-based division on two vectors.
operand | The other vector. |
|
inline |
Divides the individual components of another vector onto this vector's components.
operand | The other operand. |
|
inline |
Assigns another vector into this vector.
operand | The other vector. |
|
inline |
Checks if two vectors are exactly equal.
Due to floating point imprecision, vectors are rarely ever exactly equal. Use with care.
operand | The other vector. |
|
inline |
Accesses an individual component in this vector.
index | The component index (0 for x, 1 for y, 2 for z, 3 for w). |
|
inline |
Accesses an individual (constant) component in this vector.
Unlike the other operator[], this one works on constant vectors and returns a value that cannot be modified to alter the original vector.
index | The component index (0 for x, 1 for y, 2 for z, 3 for w). |
|
inline |
Returns a vector with each component rounded.
|
inline |
Sets all components to a given value.
value | The value to set all components to. |
|
inline |
Sets all components to the given values.
x | The x component. |
y | The y component. |
z | The z component. |
w | The w component. |
|
inline |
Gets the sum of the elements.
|
inline |
Performs a two dimensional swizzle.
Swizzles the vector allowing the components to be re-arranged into a new vector.
x | The x component (0 for x, 1 for y, 2 for z, 3 for w). |
y | The y component (0 for x, 1 for y, 2 for z, 3 for w). |
|
inline |
Performs a three dimensional swizzle.
Swizzles the vector allowing the components to be re-arranged into a new vector.
x | The x component (0 for x, 1 for y, 2 for z, 3 for w). |
y | The y component (0 for x, 1 for y, 2 for z, 3 for w). |
z | The z component (0 for x, 1 for y, 2 for z, 3 for w). |
|
inline |
Performs a four dimensional swizzle.
Swizzles the vector allowing the components to be re-arranged into a new vector.
x | The x component (0 for x, 1 for y, 2 for z, 3 for w). |
y | The y component (0 for x, 1 for y, 2 for z, 3 for w). |
z | The z component (0 for x, 1 for y, 2 for z, 3 for w). |
w | The w component (0 for x, 1 for y, 2 for z, 3 for w). |