v0.1.8
|
A three dimensional 32 bit floating point vector. More...
#include <Vector3.hpp>
Public Member Functions | |
Vector3T () | |
Initializes to (0, 0, 0). | |
Vector3T (const Vector3T ©) | |
Copies a vector into this vector. More... | |
Vector3T (const Vector2T< Type > ©) | |
Copies a vector2 into this vector3's first two components and Initializes z to 0. More... | |
Vector3T (const Vector2T< Type > ©, Type z) | |
Copies a vector2 into this vector3's first two components and Initializes z with the individual component value. More... | |
Vector3T (Type value) | |
Initializes all components to a given value. More... | |
Vector3T (Type x, Type y, Type z) | |
Initializes the vector with individual component values. More... | |
Vector3T & | operator= (const Vector3T &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... | |
Vector3T | operator- () const |
Gets the inverse of the vector. More... | |
bool | operator== (const Vector3T &operand) const |
Checks if two vectors are exactly equal. More... | |
bool | operator!= (const Vector3T &operand) const |
Checks if two vectors are not exactly equal. More... | |
Vector3T | operator+ (const Vector3T &operand) const |
Performs component-based addition on two vectors. More... | |
Vector3T & | operator+= (const Vector3T &operand) |
Adds the individual components of another vector to this vector's components. More... | |
Vector3T & | operator+= (const Vector2T< Type > &operand) |
Adds the individual components of a vector2 to this vector3's first two components. More... | |
Vector3T | operator- (const Vector3T &operand) const |
Performs component-based subtraction on two vectors. More... | |
Vector3T & | operator-= (const Vector3T &operand) |
Subtracts the individual components of another vector from this vector's components. More... | |
Vector3T & | operator-= (const Vector2T< Type > &operand) |
Subtracts the individual components of a vector2 to this vector3's first two components. More... | |
Vector3T | operator* (Type operand) const |
Performs component-based multiplication on two vectors. More... | |
Vector3T | operator* (const MatrixT< Type > &operand) const |
Vector3T & | operator*= (Type operand) |
Multiplies the individual components of another vector onto this vector's components. More... | |
Vector3T & | operator*= (const MatrixT< Type > &operand) |
Vector3T | operator/ (Type operand) const |
Performs component-based division on two vectors. More... | |
Vector3T & | operator/= (Type operand) |
Divides the individual components of another vector onto this vector's components. More... | |
template<typename OtherType > | |
operator Vector3T< 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) |
Sets all components to the given values. More... | |
void | Clear () |
Clears the vector to (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 Vector3T &other) const |
Gets the distance between two vectors. More... | |
Type | GetSquaredDistance (const Vector3T &other) const |
Gets the squared distance between two vectors. More... | |
Type | GetManhattanDistance (const Vector3T &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. | |
Vector3T | Floored () const |
Returns a vector with each component rounded down. More... | |
Vector3T | Rounded () const |
Returns a vector with each component rounded. More... | |
Vector3T | 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... | |
void | MakeOrthonormalBasis (Vector3T< Type > *vectorB, Vector3T< Type > *vectorC) |
Type | IsNaN () const |
Static Public Member Functions | |
static Type | DotProduct (const Vector3T &valueA, const Vector3T &valueB) |
static Vector3T | CrossProduct (const Vector3T &valueA, const Vector3T &valueB) |
static Vector3T | Normalized (const Vector3T &value) |
static Type | Distance (const Vector3T &vectorA, const Vector3T &vectorB) |
static Type | DistanceSquared (const Vector3T &valueA, const Vector3T &vectorB) |
static Type | DistanceManhattan (const Vector3T &valueA, const Vector3T &vectorB) |
static Vector3T | Lerp (const Vector3T &from, const Vector3T &to, Type t) |
Performs linear interpolation on a vector3. | |
Public Attributes | |
Type | x |
The x component. | |
Type | y |
The y component. | |
Type | z |
The z component. | |
Static Public Attributes | |
static const Vector3T | zero |
Zero vector, defined as (0, 0, 0). | |
static const Vector3T | one |
One vector, defined as (1, 1, 1). | |
static const Vector3T | unitX |
Unit X vector, defined as (1, 0, 0). | |
static const Vector3T | unitY |
Unit Y vector, defined as (0, 1, 0). | |
static const Vector3T | unitZ |
Unit Y vector, defined as (0, 0, 1). | |
static const Vector3T | nan |
NaN vector, defined as (NaN, NaN, NaN). | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Vector3T< Type > &vector) |
An operator to output this vector on an output stream. | |
A three dimensional 32 bit floating point vector.
|
inline |
Copies a vector into this vector.
copy | The vector to copy. |
|
inline |
Copies a vector2 into this vector3's first two components and Initializes z to 0.
copy | The vector to copy. |
|
inline |
Copies a vector2 into this vector3's first two components and Initializes z with the individual component value.
copy | The vector to copy. |
z | The z component. |
|
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. |
|
inline |
Accesses an individual component in this vector.
index | The component index, so 0 for x, 1 for y, and 2 for z. |
|
inline |
Accesses an individual (constant) component in this vector.
index | The component index, so 0 for x, 1 for y, and 2 for z. |
|
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 |
Adds the individual components of a vector2 to this vector3's first two components.
operand | The other operand. |
|
inline |
Gets the inverse of the vector.
The inverse is defined as (-x, -y, -z) 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 |
Subtracts the individual components of a vector2 to this vector3's first two 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). |
|
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). |
|
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. |
|
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). |
y | The y component (0 for x, 1 for y, 2 for z). |
|
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). |
y | The y component (0 for x, 1 for y, 2 for z). |
z | The z component (0 for x, 1 for y, 2 for z). |
|
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). |
y | The y component (0 for x, 1 for y, 2 for z). |
z | The z component (0 for x, 1 for y, 2 for z). |
w | The w component (0 for x, 1 for y, 2 for z). |