A 4-component vector class. More...
#include "murl_math_vector.h"
Public Types | |
enum | Component { X , Y , Z , W , NUM_COMPONENTS } |
Enumeration of the components raw data index. More... | |
enum | ComponentMask { MASK_NONE , MASK_X , MASK_Y , MASK_Z , MASK_W , MASK_XY , MASK_XZ , MASK_YZ , MASK_XYZ , MASK_ALL } |
Enumeration of the components' bit masks. More... | |
enum | PredefinedType { ZERO_DIRECTION , ZERO_POSITION , UNINITIALIZED } |
Enumeration of the predefined initialization types for constructing a Vector(PredefinedType type). More... | |
using | ValueType = DataType |
The template parameter value type. | |
Public Member Functions | |
Vector () | |
The default constructor. | |
template<class DataType2 > | |
Vector (const Vector< DataType2 > &v) | |
The copy constructor using a vector of different type. More... | |
Vector (DataType vx, DataType vy, DataType vz, DataType vw) | |
Constructor to initialize a vector with given component values. More... | |
Vector (const Quaternion< DataType > &q) | |
Constructor to initialize an axis/angle vector from a quaternion. More... | |
Vector (PredefinedType type) | |
Constructor to create a vector from a predefined type. More... | |
const DataType & | operator[] (UInt32 index) const |
Get a const reference to one of the 4 component values. More... | |
DataType & | operator[] (UInt32 index) |
Get a reference to one of the 4 component values. More... | |
const DataType * | GetPointer () const |
Get a const pointer to the raw data. More... | |
DataType * | GetPointer () |
Get a pointer to the raw data. More... | |
Vector & | operator+= (const Vector &v) |
In-place addition operator. More... | |
Vector & | operator-= (const Vector &v) |
In-place subtraction operator. More... | |
Vector & | operator*= (DataType v) |
In-place multiplication operator (scaling). More... | |
Vector & | operator*= (const Vector &v) |
In-place component-wise multiplication operator. More... | |
Vector & | operator/= (DataType v) |
In-place division operator (inverse scaling). More... | |
Vector & | operator/= (const Vector &v) |
In-place component-wise division operator. More... | |
Vector | operator+ (const Vector &rhs) const |
Addition operator. More... | |
Vector | operator- (const Vector &rhs) const |
Subtraction operator. More... | |
Vector | operator* (DataType rhs) const |
Multiplication (scaling) operator. More... | |
Vector | operator* (const Vector &rhs) const |
Component-wise multiplication operator. More... | |
Vector | operator/ (DataType rhs) const |
Division (inverse scaling) operator. More... | |
Vector | operator/ (const Vector &rhs) const |
Component-wise division operator. More... | |
Vector | operator- () const |
Inversion (negation) operator. More... | |
Quaternion< DataType > | operator* (const Quaternion< DataType > &rhs) const |
Multiplication operator for quaternion. More... | |
void | Clear () |
Clear all components of the vector instance. More... | |
void | Set (PredefinedType type) |
Set all components of the vector instance to the values of a given predefined type. More... | |
void | Set (const Vector &v) |
Copy the content of a source vector to the vector instance. More... | |
void | Set (DataType v) |
Set all components of the vector instance to a given value. More... | |
void | Set (DataType vx, DataType vy, DataType vz, DataType vw) |
Set all components of the vector instance to a set of given component values. More... | |
void | Set (const Quaternion< DataType > &q) |
Convert a given quaternion to an axis/angle vector. More... | |
void | AddSelf (const Vector &v) |
In-place addition. More... | |
void | SubtractSelf (const Vector &v) |
In-place subtraction. More... | |
void | MultiplySelf (DataType v) |
In-place multiplication (scaling). More... | |
void | MultiplySelf (const Vector &v) |
In-place component-wise multiplication. More... | |
void | DivideSelf (DataType v) |
In-place division (inverse scaling). More... | |
void | DivideSelf (const Vector &v) |
In-place component-wise division. More... | |
void | CrossSelf (const Vector &v) |
In-place cross product. More... | |
void | InterpolateSelf (const Vector &v, DataType t) |
In-place linear interpolation. More... | |
void | ProjectSelf (const Vector &v) |
In-place projection of a given second vector. More... | |
void | MinSelf (const Vector &v) |
In-place set each component to the minimum from the vector instance and a given second vector. More... | |
void | MaxSelf (const Vector &v) |
In-place set each component to the maximum from the vector instance and a given second vector. More... | |
void | ClampSelf (const Vector &min, const Vector &max) |
In-place clamp each component to the value range given by the min and max vector parameters. More... | |
void | MinLengthSelf (DataType v) |
Rescale the vector to a length below or equal a given minimum. More... | |
void | MaxLengthSelf (DataType v) |
Rescale the vector to a length above or equal a given maximum. More... | |
void | ClampLengthSelf (DataType min, DataType max) |
Clamp the vector to a length within a given range. More... | |
void | AbsSelf () |
Set all vector components to their absolute value. | |
void | SgnSelf () |
Set all vector components to either -1, 0 or +1 depending on their sign. | |
void | InvertSelf () |
In-place inversion (negation) of the vector instance. | |
void | NormalizeSelf () |
In-place normalization of the vector instance. More... | |
void | NormalizeAxisSelf () |
In-place normalization of the x, y and z components. More... | |
Vector | Add (const Vector &v) const |
Get the addition of a vector. More... | |
Vector | Subtract (const Vector &v) const |
Get the subtraction of a vector. More... | |
Quaternion< DataType > | Multiply (const Quaternion< DataType > &q) const |
Get the multiplication with a quaternion. More... | |
Vector | Multiply (DataType v) const |
Get the multiplication (scaling). More... | |
Vector | Multiply (const Vector &v) const |
Get the component-wise multiplication. More... | |
Vector | Divide (DataType v) const |
Get the division (inverse scaling). More... | |
Vector | Divide (const Vector &v) const |
Get the component-wise division. More... | |
Vector | Cross (const Vector &v) const |
Get the cross product. More... | |
Vector | Interpolate (const Vector &v, DataType t) const |
Get the linear interpolation. More... | |
Vector | Project (const Vector &v) const |
Get the projection of a given second vector. More... | |
Vector | Min (const Vector &v) const |
Get the minimum of each component from the vector instance and a given second vector. More... | |
Vector | Max (const Vector &v) const |
Get the maximum of each component from the vector instance and a given second vector. More... | |
Vector | Clamp (const Vector &min, const Vector &max) const |
Clamp each component to the value range given by the min and max vector parameters. More... | |
Vector | MinLength (DataType v) const |
Get a vector with a length below or equal a given minimum. More... | |
Vector | MaxLength (DataType v) const |
Get a vector with a length above or equal a given maximum. More... | |
Vector | ClampLength (DataType min, DataType max) const |
Get the a vector with clamped length. More... | |
Vector | Abs () const |
Get a vector containing absolute values for each of the instance's components. More... | |
Vector | Sgn () const |
Get a vector containing component values of either -1, 0 or +1, depending on the instance component's signs. More... | |
Vector | Invert () const |
Get the inversion (negation) of the vector instance. More... | |
Vector | Normalize () const |
Get the normalization of the vector instance. More... | |
Vector | NormalizeAxis () const |
Get the normalization of the x, y and z components. More... | |
DataType | Dot (const Vector &v) const |
Get the dot product of the vector instance and a given second vector. More... | |
DataType | GetLength () const |
Get the length of the vector instance. More... | |
DataType | GetSquaredLength () const |
Get the squared length of the vector instance. More... | |
DataType | GetAngle2D () const |
Get the x/y angle of the vector instance. More... | |
Bool | IsZero () const |
Check if the vector instance equals the null vector. More... | |
Bool | IsZero (DataType epsilon) const |
Check if the vector instance equals the null vector. More... | |
Bool | IsZeroPosition () const |
Check if the vector instance equals the zero position. More... | |
Bool | IsZeroPosition (DataType epsilon) const |
Check if the vector instance equals the zero position. More... | |
Bool | IsEqual (const Vector &v) const |
Check if the vector instance is equal to a given second vector. More... | |
Bool | IsEqual (const Vector &v, DataType epsilon) const |
Check if the vector instance is equal to a given second vector. More... | |
Bool | GetBaseNormals (Vector &n1, Vector &n2, Vector &n3) const |
Get base vectors for this vector instance. More... | |
String | ToString () const |
Get the string representation of the object. More... | |
SInt32 | GetCount () const |
Get the number of elements in the object. More... | |
Public Attributes | |
union { | |
DataType mComponents [NUM_COMPONENTS] | |
The components data array. | |
struct { | |
DataType x | |
The X component. | |
DataType y | |
The Y component. | |
DataType z | |
The Z component. | |
DataType w | |
The W component. | |
} | |
The components member struct. | |
}; | |
The components storage union overlaps the raw data array mComponents and the component structure. | |
Friends | |
bool | operator== (const Vector< DataType > &lhs, const Vector< DataType > &rhs) |
Equal to comparison operator. More... | |
bool | operator!= (const Vector< DataType > &lhs, const Vector< DataType > &rhs) |
Not equal to comparison operator. More... | |
Detailed Description
template<class DataType>
class Murl::Math::Vector< DataType >
A 4-component vector class.
Member Enumeration Documentation
◆ Component
enum Murl::Math::Vector::Component |
◆ ComponentMask
enum Murl::Math::Vector::ComponentMask |
Enumeration of the components' bit masks.
◆ PredefinedType
enum Murl::Math::Vector::PredefinedType |
Enumeration of the predefined initialization types for constructing a Vector(PredefinedType type).
Enumerator | |
---|---|
ZERO_DIRECTION | Initialize with zero direction {0, 0, 0, 0}. |
ZERO_POSITION | Initialize with zero position {0, 0, 0, 1}. |
UNINITIALIZED | Create an uninitialized instance. |
Constructor & Destructor Documentation
◆ Vector() [1/4]
|
inline |
The copy constructor using a vector of different type.
- Parameters
-
v The vector to copy.
◆ Vector() [2/4]
|
inline |
Constructor to initialize a vector with given component values.
- Parameters
-
vx The x component. vy The y component. vz The z component. vw The w component.
◆ Vector() [3/4]
|
inline |
Constructor to initialize an axis/angle vector from a quaternion.
- Parameters
-
q The quaternion.
References Murl::Math::Vector< DataType >::Set().
◆ Vector() [4/4]
|
inline |
Constructor to create a vector from a predefined type.
- Parameters
-
type The predefined type.
References Murl::Math::Vector< DataType >::Set().
Member Function Documentation
◆ operator[]() [1/2]
|
inline |
Get a const reference to one of the 4 component values.
- Parameters
-
index The component index, see enum Component.
- Returns
- The component value const reference.
◆ operator[]() [2/2]
|
inline |
Get a reference to one of the 4 component values.
- Parameters
-
index The component index, see enum Component.
- Returns
- The component value reference.
◆ GetPointer() [1/2]
|
inline |
Get a const pointer to the raw data.
- Returns
- Const pointer to the raw data.
References Murl::Math::Vector< DataType >::mComponents.
◆ GetPointer() [2/2]
|
inline |
Get a pointer to the raw data.
- Returns
- Pointer to the raw data.
References Murl::Math::Vector< DataType >::mComponents.
◆ operator+=()
|
inline |
In-place addition operator.
- Parameters
-
v The vector to add.
- Returns
- The object itself.
References Murl::Math::Vector< DataType >::AddSelf().
◆ operator-=()
|
inline |
In-place subtraction operator.
- Parameters
-
v The vector to subtract.
- Returns
- The object itself.
References Murl::Math::Vector< DataType >::SubtractSelf().
◆ operator*=() [1/2]
|
inline |
In-place multiplication operator (scaling).
- Parameters
-
v The value to multiply.
- Returns
- The object itself.
References Murl::Math::Vector< DataType >::MultiplySelf().
◆ operator*=() [2/2]
|
inline |
In-place component-wise multiplication operator.
- Parameters
-
v The vector to multiply.
- Returns
- The object itself.
References Murl::Math::Vector< DataType >::MultiplySelf().
◆ operator/=() [1/2]
|
inline |
In-place division operator (inverse scaling).
- Parameters
-
v The value to divide.
- Returns
- The object itself.
References Murl::Math::Vector< DataType >::DivideSelf().
◆ operator/=() [2/2]
|
inline |
In-place component-wise division operator.
- Parameters
-
v The vector to multiply.
- Returns
- The object itself.
References Murl::Math::Vector< DataType >::DivideSelf().
◆ operator+()
|
inline |
Addition operator.
- Parameters
-
rhs The right hand side vector.
- Returns
- The added vector.
References Murl::Math::Vector< DataType >::Add().
◆ operator-() [1/2]
|
inline |
Subtraction operator.
- Parameters
-
rhs The right hand side vector.
- Returns
- The subtracted vector.
References Murl::Math::Vector< DataType >::Subtract().
◆ operator*() [1/3]
|
inline |
Multiplication (scaling) operator.
- Parameters
-
rhs The right hand side value.
- Returns
- The multiplied vector.
References Murl::Math::Vector< DataType >::Multiply().
◆ operator*() [2/3]
|
inline |
Component-wise multiplication operator.
- Parameters
-
rhs The right hand side vector.
- Returns
- The multiplied vector.
References Murl::Math::Vector< DataType >::Multiply().
◆ operator/() [1/2]
|
inline |
Division (inverse scaling) operator.
- Parameters
-
rhs The right hand side value.
- Returns
- The divided vector.
References Murl::Math::Vector< DataType >::Divide().
◆ operator/() [2/2]
|
inline |
Component-wise division operator.
- Parameters
-
rhs The right hand side vector.
- Returns
- The divided vector.
References Murl::Math::Vector< DataType >::Divide().
◆ operator-() [2/2]
|
inline |
Inversion (negation) operator.
- Returns
- The inverted vector.
References Murl::Math::Vector< DataType >::Invert().
◆ operator*() [3/3]
|
inline |
Multiplication operator for quaternion.
- Parameters
-
rhs The right hand side quaternion.
- Returns
- The multiplied Quaternion.
References Murl::Math::Vector< DataType >::Multiply().
◆ Clear()
|
inline |
Clear all components of the vector instance.
Set all components to default constructor of data type.
◆ Set() [1/5]
|
inline |
Set all components of the vector instance to the values of a given predefined type.
- Parameters
-
type The value to set.
References Murl::Math::Vector< DataType >::UNINITIALIZED, Murl::Math::Vector< DataType >::ZERO_DIRECTION, and Murl::Math::Vector< DataType >::ZERO_POSITION.
Referenced by Murl::Math::Vector< DataType >::ClampLengthSelf(), Murl::Math::Vector< DataType >::GetBaseNormals(), Murl::Math::Vector< DataType >::MaxLengthSelf(), Murl::Math::Vector< DataType >::MinLengthSelf(), and Murl::Math::Vector< DataType >::Vector().
◆ Set() [2/5]
|
inline |
Copy the content of a source vector to the vector instance.
- Parameters
-
v The vector to copy from.
◆ Set() [3/5]
|
inline |
Set all components of the vector instance to a given value.
- Parameters
-
v The value to set.
◆ Set() [4/5]
|
inline |
Set all components of the vector instance to a set of given component values.
- Parameters
-
vx The x-component value to set. vy The y-component value to set. vz The z-component value to set. vw The w-component value to set.
◆ Set() [5/5]
|
inline |
Convert a given quaternion to an axis/angle vector.
- Parameters
-
q The quaternion to convert from.
References Murl::Math::ArcCos(), Murl::Math::Vector< DataType >::GetSquaredLength(), Murl::Math::Quaternion< DataType >::i, Murl::Math::Quaternion< DataType >::j, Murl::Math::Quaternion< DataType >::k, Murl::Math::Quaternion< DataType >::NormalizeSelf(), Murl::Math::Quaternion< DataType >::r, and Murl::Math::Sqrt().
◆ AddSelf()
|
inline |
In-place addition.
- Parameters
-
v The vector to add.
Referenced by Murl::Math::Vector< DataType >::operator+=().
◆ SubtractSelf()
|
inline |
In-place subtraction.
- Parameters
-
v The vector to subtract.
Referenced by Murl::Math::Vector< DataType >::operator-=().
◆ MultiplySelf() [1/2]
|
inline |
In-place multiplication (scaling).
- Parameters
-
v The value to multiply.
Referenced by Murl::Math::Vector< DataType >::operator*=(), and Murl::Math::Vector< DataType >::ProjectSelf().
◆ MultiplySelf() [2/2]
|
inline |
In-place component-wise multiplication.
- Parameters
-
v The vector to multiply.
◆ DivideSelf() [1/2]
|
inline |
In-place division (inverse scaling).
- Parameters
-
v The value to divide.
Referenced by Murl::Math::Vector< DataType >::operator/=().
◆ DivideSelf() [2/2]
|
inline |
In-place component-wise division.
- Parameters
-
v The vector to divide.
◆ CrossSelf()
|
inline |
In-place cross product.
- Parameters
-
v The vector to cross.
◆ InterpolateSelf()
|
inline |
In-place linear interpolation.
Interpolation along a straight line between the vector instance (first vector) and a given second vector. For t=0.0, the result equals the first vector and for t=1.0 the second one.
- Parameters
-
v The vector to interpolate. t The distance for interplation.
◆ ProjectSelf()
|
inline |
In-place projection of a given second vector.
Project the given second vector onto the vector instance (first vector). The first vector gets normalized and then multiplied by the length retrieved from a dot-product multiplication between the two vectors (i.e. the vector instance retains its direction, but retrieves the length of the projection).
- Parameters
-
v The vector to project from.
References Murl::Math::Vector< DataType >::Dot(), Murl::Math::Vector< DataType >::MultiplySelf(), and Murl::Math::Vector< DataType >::NormalizeSelf().
◆ MinSelf()
|
inline |
In-place set each component to the minimum from the vector instance and a given second vector.
- Parameters
-
v The vector to evaluate the minimum from.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Vector< DataType >::ClampSelf().
◆ MaxSelf()
|
inline |
In-place set each component to the maximum from the vector instance and a given second vector.
- Parameters
-
v The vector to evaluate the maximum from.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Vector< DataType >::ClampSelf().
◆ ClampSelf()
|
inline |
In-place clamp each component to the value range given by the min and max vector parameters.
- Parameters
-
min The component-wise minimum to clamp to. max The component-wise maximum to clamp to.
References Murl::Math::Vector< DataType >::MaxSelf(), and Murl::Math::Vector< DataType >::MinSelf().
Referenced by Murl::Math::Vector< DataType >::Clamp().
◆ MinLengthSelf()
|
inline |
Rescale the vector to a length below or equal a given minimum.
See MinLength().
- Parameters
-
v The minimum length.
References Murl::Math::Vector< DataType >::MinLength(), and Murl::Math::Vector< DataType >::Set().
◆ MaxLengthSelf()
|
inline |
Rescale the vector to a length above or equal a given maximum.
See MaxLength().
- Parameters
-
v The maximum length.
References Murl::Math::Vector< DataType >::MaxLength(), and Murl::Math::Vector< DataType >::Set().
◆ ClampLengthSelf()
|
inline |
Clamp the vector to a length within a given range.
See ClampLength().
- Parameters
-
min The minimum length. max The maximum length.
References Murl::Math::Vector< DataType >::ClampLength(), and Murl::Math::Vector< DataType >::Set().
◆ NormalizeSelf()
|
inline |
In-place normalization of the vector instance.
Normalization retains the direction and sets the length to 1.0.
References Murl::Math::Vector< DataType >::GetLength().
Referenced by Murl::Math::Vector< DataType >::ProjectSelf().
◆ NormalizeAxisSelf()
|
inline |
In-place normalization of the x, y and z components.
Calculates the normalization without touching the w component, for normalizing the axis of an axis/angle representation.
References Murl::Math::Vector< DataType >::GetLength().
◆ Add()
|
inline |
Get the addition of a vector.
- Parameters
-
v The vector to add.
- Returns
- The added vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Vector< DataType >::operator+().
◆ Subtract()
|
inline |
Get the subtraction of a vector.
- Parameters
-
v The vector to subtract.
- Returns
- The subtracted vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Vector< DataType >::operator-().
◆ Multiply() [1/3]
|
inline |
Get the multiplication with a quaternion.
- Parameters
-
q The quaternion to multiply.
- Returns
- The multiplied quaternion.
References Murl::Math::Quaternion< DataType >::i, Murl::Math::Quaternion< DataType >::j, Murl::Math::Quaternion< DataType >::k, and Murl::Math::Quaternion< DataType >::r.
Referenced by Murl::Math::Vector< DataType >::operator*(), and Murl::Math::Vector< DataType >::Project().
◆ Multiply() [2/3]
|
inline |
Get the multiplication (scaling).
- Parameters
-
v The value to multiply.
- Returns
- The multiplied vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ Multiply() [3/3]
|
inline |
Get the component-wise multiplication.
- Parameters
-
v The vector to multiply.
- Returns
- The multiplied vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ Divide() [1/2]
|
inline |
Get the division (inverse scaling).
- Parameters
-
v The value to divide.
- Returns
- The divided vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Vector< DataType >::operator/().
◆ Divide() [2/2]
|
inline |
Get the component-wise division.
- Parameters
-
v The vector to divide.
- Returns
- The divided vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ Cross()
|
inline |
Get the cross product.
- Parameters
-
v The vector to cross.
- Returns
- The cross product vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Vector< DataType >::GetBaseNormals(), Murl::Math::Matrix< DataType >::LookAt(), and Murl::Math::Sphere< DataType >::SetBounding().
◆ Interpolate()
|
inline |
Get the linear interpolation.
Interpolation along a straight line between the vector instance (first vector) and a given second vector. For t=0.0, the result equals the first vector and for t=1.0 the second one.
- Parameters
-
v The vector to interpolate. t The interpolation factor.
- Returns
- The interpolated vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ Project()
|
inline |
Get the projection of a given second vector.
Project the given second vector onto the vector instance (first vector). The first vector gets normalized and then multiplied by the length retrieved from a dot-product multiplication between the two vectors (i.e. the vector instance retains its direction, but retrieves the length of the projection).
- Parameters
-
v The vector to project from.
- Returns
- The projected vector.
References Murl::Math::Vector< DataType >::Dot(), Murl::Math::Vector< DataType >::Multiply(), and Murl::Math::Vector< DataType >::Normalize().
◆ Min()
|
inline |
Get the minimum of each component from the vector instance and a given second vector.
- Parameters
-
v The vector to evaluate the minimum from.
- Returns
- The minimum vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Box< DataType >::Set().
◆ Max()
|
inline |
Get the maximum of each component from the vector instance and a given second vector.
- Parameters
-
v The vector to evaluate the maximum from.
- Returns
- The maximum vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Box< DataType >::Set().
◆ Clamp()
|
inline |
Clamp each component to the value range given by the min and max vector parameters.
- Parameters
-
min The component-wise minimum to clamp to. max The component-wise maximum to clamp to.
- Returns
- The clamped vector.
References Murl::Math::Vector< DataType >::ClampSelf().
◆ MinLength()
|
inline |
Get a vector with a length below or equal a given minimum.
If the current vector's length is below or equal the given minimum value, the vector is directly returned. Otherwise a scaled vector is returned, with the original direction and given length.
- Parameters
-
v The minimum length.
- Returns
- A minimum length vector.
References Murl::Math::Vector< DataType >::GetLength(), Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, Murl::Math::Vector< DataType >::z, Murl::Math::Vector< DataType >::ZERO_DIRECTION, and Murl::Math::Vector< DataType >::ZERO_POSITION.
Referenced by Murl::Math::Vector< DataType >::MinLengthSelf().
◆ MaxLength()
|
inline |
Get a vector with a length above or equal a given maximum.
If the current vector's length is above or equal the given maximum value, the vector is directly returned. Otherwise a scaled vector is returned, with the original direction and given length. If the vector has zero length (i.e. undefined direction) a zero vector is returned with its w component set to either 0 or 1, depending on the current vector's w value.
- Parameters
-
v The maximum length.
- Returns
- A maximum length vector.
References Murl::Math::Vector< DataType >::GetLength(), Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, Murl::Math::Vector< DataType >::z, Murl::Math::Vector< DataType >::ZERO_DIRECTION, and Murl::Math::Vector< DataType >::ZERO_POSITION.
Referenced by Murl::Math::Vector< DataType >::MaxLengthSelf().
◆ ClampLength()
|
inline |
Get the a vector with clamped length.
This method returns a vector in the direction of the vector instance, but with its length clamped to the given range.
- Parameters
-
min The minimum length. max The maximum length.
- Returns
- A clamped vector.
References Murl::Math::Vector< DataType >::GetLength(), Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, Murl::Math::Vector< DataType >::z, Murl::Math::Vector< DataType >::ZERO_DIRECTION, and Murl::Math::Vector< DataType >::ZERO_POSITION.
Referenced by Murl::Math::Vector< DataType >::ClampLengthSelf().
◆ Abs()
|
inline |
Get a vector containing absolute values for each of the instance's components.
- Returns
- The resulting vector.
References Murl::Math::Abs(), Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ Sgn()
|
inline |
Get a vector containing component values of either -1, 0 or +1, depending on the instance component's signs.
- Returns
- The resulting vector.
References Murl::Math::Vector< DataType >::mComponents.
◆ Invert()
|
inline |
Get the inversion (negation) of the vector instance.
- Returns
- The inverted vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Vector< DataType >::operator-().
◆ Normalize()
|
inline |
Get the normalization of the vector instance.
Normalization retains the direction and sets the length to 1.0.
- Returns
- The normalized vector.
References Murl::Math::Vector< DataType >::GetLength(), Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
Referenced by Murl::Math::Vector< DataType >::GetBaseNormals(), Murl::Math::Matrix< DataType >::LookAt(), and Murl::Math::Vector< DataType >::Project().
◆ NormalizeAxis()
|
inline |
Get the normalization of the x, y and z components.
Calculates the normalization without touching the w component, for normalizing the axis of an axis/angle representation.
- Returns
- The normalized axis vector.
References Murl::Math::Vector< DataType >::GetLength(), Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ Dot()
|
inline |
Get the dot product of the vector instance and a given second vector.
- Parameters
-
v The second vector.
- Returns
- The dot product.
Referenced by Murl::Math::Vector< DataType >::Project(), Murl::Math::Vector< DataType >::ProjectSelf(), and Murl::Math::Sphere< DataType >::SetContaining().
◆ GetLength()
|
inline |
Get the length of the vector instance.
- Returns
- The length of the vector.
References Murl::Math::Sqrt().
Referenced by Murl::Math::Vector< DataType >::ClampLength(), Murl::Math::Vector< DataType >::MaxLength(), Murl::Math::Vector< DataType >::MinLength(), Murl::Math::Vector< DataType >::Normalize(), Murl::Math::Vector< DataType >::NormalizeAxis(), Murl::Math::Vector< DataType >::NormalizeAxisSelf(), Murl::Math::Vector< DataType >::NormalizeSelf(), and Murl::Math::Sphere< DataType >::Unite().
◆ GetSquaredLength()
|
inline |
Get the squared length of the vector instance.
- Returns
- The squared length of the vector.
Referenced by Murl::Math::Sphere< DataType >::Include(), Murl::Math::Cone< DataType >::IsIntersecting(), Murl::Math::Vector< DataType >::Set(), and Murl::Math::Sphere< DataType >::SetBounding().
◆ GetAngle2D()
|
inline |
Get the x/y angle of the vector instance.
- Returns
- The angle in radians [0 .. 2π].
References Murl::Math::ArcCos(), Murl::Math::Sqrt(), and Murl::Math::TWO_PI.
◆ IsZero() [1/2]
|
inline |
Check if the vector instance equals the null vector.
Compares all values within the default epsilon range Limits::Epsilon().
- Returns
- true if equals the null vector.
Referenced by Murl::Math::Vector< DataType >::GetBaseNormals().
◆ IsZero() [2/2]
|
inline |
Check if the vector instance equals the null vector.
Compares all values within a given epsilon range.
- Parameters
-
epsilon The epsilon to compare.
- Returns
- true if equals the null vector.
References Murl::Math::Vector< DataType >::w, Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ IsZeroPosition() [1/2]
|
inline |
Check if the vector instance equals the zero position.
Compares the x, y and z values within the default epsilon range Limits::Epsilon().
- Returns
- true if equals the null vector.
◆ IsZeroPosition() [2/2]
|
inline |
Check if the vector instance equals the zero position.
Compares the x, y and z values within a given epsilon range.
- Parameters
-
epsilon The epsilon to compare.
- Returns
- true if equals the null vector.
References Murl::Math::Vector< DataType >::x, Murl::Math::Vector< DataType >::y, and Murl::Math::Vector< DataType >::z.
◆ IsEqual() [1/2]
|
inline |
Check if the vector instance is equal to a given second vector.
Compares all values within the default epsilon range Limits::Epsilon().
- Parameters
-
v The vector to compare.
- Returns
- true if equal to the compared vector.
◆ IsEqual() [2/2]
|
inline |
Check if the vector instance is equal to a given second vector.
Compares all values within a given epsilon range.
- Parameters
-
v The vector to compare. epsilon The epsilon to compare.
- Returns
- true if equal to the compared vector.
References Murl::Math::Abs().
◆ GetBaseNormals()
|
inline |
Get base vectors for this vector instance.
This method tries to calculate three direction vectors from the current instance, so that they form an orthonormal base. If the current vector has zero length, false is returned.
- Parameters
-
n1 Base vector 1 n2 Base vector 2 n3 Base vector 3
- Returns
- true if successful.
References Murl::Math::Abs(), Murl::Math::Vector< DataType >::Cross(), Murl::Math::Vector< DataType >::IsZero(), Murl::Math::Vector< DataType >::Normalize(), Murl::Math::Vector< DataType >::Set(), and Murl::Math::Vector< DataType >::w.
◆ ToString()
|
inline |
Get the string representation of the object.
- Returns
- The string representation of the object.
References Murl::Util::PrintToString().
◆ GetCount()
|
inline |
Get the number of elements in the object.
- Returns
- The number of elements in the object.
References Murl::Math::Vector< DataType >::NUM_COMPONENTS.
Friends And Related Function Documentation
◆ operator==
|
friend |
Equal to comparison operator.
Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Vector> class. To compare within an epsilon range use Vector::IsEqual().
- Parameters
-
lhs The left hand side vector to compare. rhs The right hand side vector to compare.
- Returns
- true if all components are exactly the same.
◆ operator!=
|
friend |
Not equal to comparison operator.
Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Vector> class. To compare within an epsilon range use Vector::IsEqual().
- Parameters
-
lhs The left hand side vector to compare. rhs The right hand side vector to compare.
- Returns
- true if all components are not exactly the same.
The documentation for this class was generated from the following files:
- murl_app_types.h
- murl_math_vector.h