Murl::Math::Vector< DataType > Class Template Reference

A 4-component vector class. More...

#include "murl_math_vector.h"

Inheritance diagram for Murl::Math::Vector< DataType >:

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...
 
typedef DataType ValueType
 The template parameter value type. More...
 

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...
 
Vectoroperator+= (const Vector &v)
 In-place addition operator. More...
 
Vectoroperator-= (const Vector &v)
 In-place subtraction operator. More...
 
Vectoroperator*= (DataType v)
 In-place multiplication operator (scaling). More...
 
Vectoroperator*= (const Vector &v)
 In-place component-wise multiplication operator. More...
 
Vectoroperator/= (DataType v)
 In-place division operator (inverse scaling). More...
 
Vectoroperator/= (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. More...
 
   struct {
      DataType   x
 The X component. More...
 
      DataType   y
 The Y component. More...
 
      DataType   z
 The Z component. More...
 
      DataType   w
 The W component. More...
 
   } 
 The components member struct. More...
 
}; 
 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 Typedef Documentation

◆ ValueType

template<class DataType>
typedef DataType Murl::Math::Vector< DataType >::ValueType

The template parameter value type.

Member Enumeration Documentation

◆ Component

template<class DataType>
enum Murl::Math::Vector::Component

Enumeration of the components raw data index.

The components can be accessed by using the [] operator.

Enumerator

The index to the X component.

The index to the Y component.

The index to the Z component.

The index to the W component.

NUM_COMPONENTS 

The number of components.

◆ ComponentMask

template<class DataType>
enum Murl::Math::Vector::ComponentMask

Enumeration of the components' bit masks.

Enumerator
MASK_NONE 

No component.

MASK_X 

X component mask.

MASK_Y 

Y component mask.

MASK_Z 

Z component mask.

MASK_W 

W component mask.

MASK_XY 

Component mask for X and Y.

MASK_XZ 

Component mask for X and Z.

MASK_YZ 

Component mask for Y and Z.

MASK_XYZ 

Component mask for X, Y and Z.

MASK_ALL 

All components.

◆ PredefinedType

template<class DataType>
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]

template<class DataType>
template<class DataType2 >
Murl::Math::Vector< DataType >::Vector ( const Vector< DataType2 > &  v)
inline

The copy constructor using a vector of different type.

Parameters
vThe vector to copy.

◆ Vector() [2/4]

template<class DataType>
Murl::Math::Vector< DataType >::Vector ( DataType  vx,
DataType  vy,
DataType  vz,
DataType  vw 
)
inline

Constructor to initialize a vector with given component values.

Parameters
vxThe x component.
vyThe y component.
vzThe z component.
vwThe w component.

◆ Vector() [3/4]

template<class DataType>
Murl::Math::Vector< DataType >::Vector ( const Quaternion< DataType > &  q)
inline

Constructor to initialize an axis/angle vector from a quaternion.

Parameters
qThe quaternion.

◆ Vector() [4/4]

template<class DataType>
Murl::Math::Vector< DataType >::Vector ( PredefinedType  type)
inline

Constructor to create a vector from a predefined type.

Parameters
typeThe predefined type.

Member Function Documentation

◆ operator[]() [1/2]

template<class DataType>
const DataType& Murl::Math::Vector< DataType >::operator[] ( UInt32  index) const
inline

Get a const reference to one of the 4 component values.

Parameters
indexThe component index, see enum Component.
Returns
The component value const reference.

◆ operator[]() [2/2]

template<class DataType>
DataType& Murl::Math::Vector< DataType >::operator[] ( UInt32  index)
inline

Get a reference to one of the 4 component values.

Parameters
indexThe component index, see enum Component.
Returns
The component value reference.

◆ GetPointer() [1/2]

template<class DataType>
const DataType* Murl::Math::Vector< DataType >::GetPointer ( ) const
inline

Get a const pointer to the raw data.

Returns
Const pointer to the raw data.

◆ GetPointer() [2/2]

template<class DataType>
DataType* Murl::Math::Vector< DataType >::GetPointer ( )
inline

Get a pointer to the raw data.

Returns
Pointer to the raw data.

◆ operator+=()

template<class DataType>
Vector& Murl::Math::Vector< DataType >::operator+= ( const Vector< DataType > &  v)
inline

In-place addition operator.

Parameters
vThe vector to add.
Returns
The object itself.

◆ operator-=()

template<class DataType>
Vector& Murl::Math::Vector< DataType >::operator-= ( const Vector< DataType > &  v)
inline

In-place subtraction operator.

Parameters
vThe vector to subtract.
Returns
The object itself.

◆ operator*=() [1/2]

template<class DataType>
Vector& Murl::Math::Vector< DataType >::operator*= ( DataType  v)
inline

In-place multiplication operator (scaling).

Parameters
vThe value to multiply.
Returns
The object itself.

◆ operator*=() [2/2]

template<class DataType>
Vector& Murl::Math::Vector< DataType >::operator*= ( const Vector< DataType > &  v)
inline

In-place component-wise multiplication operator.

Parameters
vThe vector to multiply.
Returns
The object itself.

◆ operator/=() [1/2]

template<class DataType>
Vector& Murl::Math::Vector< DataType >::operator/= ( DataType  v)
inline

In-place division operator (inverse scaling).

Parameters
vThe value to divide.
Returns
The object itself.

◆ operator/=() [2/2]

template<class DataType>
Vector& Murl::Math::Vector< DataType >::operator/= ( const Vector< DataType > &  v)
inline

In-place component-wise division operator.

Parameters
vThe vector to multiply.
Returns
The object itself.

◆ operator+()

template<class DataType>
Vector Murl::Math::Vector< DataType >::operator+ ( const Vector< DataType > &  rhs) const
inline

Addition operator.

Parameters
rhsThe right hand side vector.
Returns
The added vector.

◆ operator-() [1/2]

template<class DataType>
Vector Murl::Math::Vector< DataType >::operator- ( const Vector< DataType > &  rhs) const
inline

Subtraction operator.

Parameters
rhsThe right hand side vector.
Returns
The subtracted vector.

◆ operator*() [1/3]

template<class DataType>
Vector Murl::Math::Vector< DataType >::operator* ( DataType  rhs) const
inline

Multiplication (scaling) operator.

Parameters
rhsThe right hand side value.
Returns
The multiplied vector.

◆ operator*() [2/3]

template<class DataType>
Vector Murl::Math::Vector< DataType >::operator* ( const Vector< DataType > &  rhs) const
inline

Component-wise multiplication operator.

Parameters
rhsThe right hand side vector.
Returns
The multiplied vector.

◆ operator/() [1/2]

template<class DataType>
Vector Murl::Math::Vector< DataType >::operator/ ( DataType  rhs) const
inline

Division (inverse scaling) operator.

Parameters
rhsThe right hand side value.
Returns
The divided vector.

◆ operator/() [2/2]

template<class DataType>
Vector Murl::Math::Vector< DataType >::operator/ ( const Vector< DataType > &  rhs) const
inline

Component-wise division operator.

Parameters
rhsThe right hand side vector.
Returns
The divided vector.

◆ operator-() [2/2]

template<class DataType>
Vector Murl::Math::Vector< DataType >::operator- ( ) const
inline

Inversion (negation) operator.

Returns
The inverted vector.

◆ operator*() [3/3]

template<class DataType>
Quaternion<DataType> Murl::Math::Vector< DataType >::operator* ( const Quaternion< DataType > &  rhs) const
inline

Multiplication operator for quaternion.

Parameters
rhsThe right hand side quaternion.
Returns
The multiplied Quaternion.

◆ Clear()

template<class DataType>
void Murl::Math::Vector< DataType >::Clear ( )
inline

Clear all components of the vector instance.

Set all components to default constructor of data type.

◆ Set() [1/5]

template<class DataType>
void Murl::Math::Vector< DataType >::Set ( PredefinedType  type)
inline

Set all components of the vector instance to the values of a given predefined type.

Parameters
typeThe value to set.

Referenced by Murl::Math::Vector< Real >::ClampLengthSelf(), Murl::Math::Vector< Real >::MaxLengthSelf(), Murl::Math::Vector< Real >::MinLengthSelf(), and Murl::Math::Vector< Real >::Vector().

◆ Set() [2/5]

template<class DataType>
void Murl::Math::Vector< DataType >::Set ( const Vector< DataType > &  v)
inline

Copy the content of a source vector to the vector instance.

Parameters
vThe vector to copy from.

◆ Set() [3/5]

template<class DataType>
void Murl::Math::Vector< DataType >::Set ( DataType  v)
inline

Set all components of the vector instance to a given value.

Parameters
vThe value to set.

◆ Set() [4/5]

template<class DataType>
void Murl::Math::Vector< DataType >::Set ( DataType  vx,
DataType  vy,
DataType  vz,
DataType  vw 
)
inline

Set all components of the vector instance to a set of given component values.

Parameters
vxThe x-component value to set.
vyThe y-component value to set.
vzThe z-component value to set.
vwThe w-component value to set.

◆ Set() [5/5]

template<class DataType>
void Murl::Math::Vector< DataType >::Set ( const Quaternion< DataType > &  q)
inline

Convert a given quaternion to an axis/angle vector.

Parameters
qThe quaternion to convert from.

◆ AddSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::AddSelf ( const Vector< DataType > &  v)
inline

In-place addition.

Parameters
vThe vector to add.

Referenced by Murl::Math::Vector< Real >::operator+=().

◆ SubtractSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::SubtractSelf ( const Vector< DataType > &  v)
inline

In-place subtraction.

Parameters
vThe vector to subtract.

Referenced by Murl::Math::Vector< Real >::operator-=().

◆ MultiplySelf() [1/2]

template<class DataType>
void Murl::Math::Vector< DataType >::MultiplySelf ( DataType  v)
inline

In-place multiplication (scaling).

Parameters
vThe value to multiply.

Referenced by Murl::Math::Vector< Real >::operator*=(), and Murl::Math::Vector< Real >::ProjectSelf().

◆ MultiplySelf() [2/2]

template<class DataType>
void Murl::Math::Vector< DataType >::MultiplySelf ( const Vector< DataType > &  v)
inline

In-place component-wise multiplication.

Parameters
vThe vector to multiply.

◆ DivideSelf() [1/2]

template<class DataType>
void Murl::Math::Vector< DataType >::DivideSelf ( DataType  v)
inline

In-place division (inverse scaling).

Parameters
vThe value to divide.

Referenced by Murl::Math::Vector< Real >::operator/=().

◆ DivideSelf() [2/2]

template<class DataType>
void Murl::Math::Vector< DataType >::DivideSelf ( const Vector< DataType > &  v)
inline

In-place component-wise division.

Parameters
vThe vector to divide.

◆ CrossSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::CrossSelf ( const Vector< DataType > &  v)
inline

In-place cross product.

Parameters
vThe vector to cross.

◆ InterpolateSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::InterpolateSelf ( const Vector< DataType > &  v,
DataType  t 
)
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
vThe vector to interpolate.
tThe distance for interplation.

◆ ProjectSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::ProjectSelf ( const Vector< DataType > &  v)
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
vThe vector to project from.

◆ MinSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::MinSelf ( const Vector< DataType > &  v)
inline

In-place set each component to the minimum from the vector instance and a given second vector.

Parameters
vThe vector to evaluate the minimum from.

Referenced by Murl::Math::Vector< Real >::ClampSelf().

◆ MaxSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::MaxSelf ( const Vector< DataType > &  v)
inline

In-place set each component to the maximum from the vector instance and a given second vector.

Parameters
vThe vector to evaluate the maximum from.

Referenced by Murl::Math::Vector< Real >::ClampSelf().

◆ ClampSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::ClampSelf ( const Vector< DataType > &  min,
const Vector< DataType > &  max 
)
inline

In-place clamp each component to the value range given by the min and max vector parameters.

Parameters
minThe component-wise minimum to clamp to.
maxThe component-wise maximum to clamp to.

◆ MinLengthSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::MinLengthSelf ( DataType  v)
inline

Rescale the vector to a length below or equal a given minimum.

See MinLength().

Parameters
vThe minimum length.

◆ MaxLengthSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::MaxLengthSelf ( DataType  v)
inline

Rescale the vector to a length above or equal a given maximum.

See MaxLength().

Parameters
vThe maximum length.

◆ ClampLengthSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::ClampLengthSelf ( DataType  min,
DataType  max 
)
inline

Clamp the vector to a length within a given range.

See ClampLength().

Parameters
minThe minimum length.
maxThe maximum length.

◆ NormalizeSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::NormalizeSelf ( )
inline

In-place normalization of the vector instance.

Normalization retains the direction and sets the length to 1.0.

Referenced by Murl::Math::Vector< Real >::ProjectSelf().

◆ NormalizeAxisSelf()

template<class DataType>
void Murl::Math::Vector< DataType >::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.

◆ Add()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Add ( const Vector< DataType > &  v) const
inline

Get the addition of a vector.

Parameters
vThe vector to add.
Returns
The added vector.

Referenced by Murl::Math::Vector< Real >::operator+().

◆ Subtract()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Subtract ( const Vector< DataType > &  v) const
inline

Get the subtraction of a vector.

Parameters
vThe vector to subtract.
Returns
The subtracted vector.

Referenced by Murl::Math::Vector< Real >::operator-().

◆ Multiply() [1/3]

template<class DataType>
Quaternion<DataType> Murl::Math::Vector< DataType >::Multiply ( const Quaternion< DataType > &  q) const
inline

Get the multiplication with a quaternion.

Parameters
qThe quaternion to multiply.
Returns
The multiplied quaternion.

Referenced by Murl::Math::Vector< Real >::operator*().

◆ Multiply() [2/3]

template<class DataType>
Vector Murl::Math::Vector< DataType >::Multiply ( DataType  v) const
inline

Get the multiplication (scaling).

Parameters
vThe value to multiply.
Returns
The multiplied vector.

◆ Multiply() [3/3]

template<class DataType>
Vector Murl::Math::Vector< DataType >::Multiply ( const Vector< DataType > &  v) const
inline

Get the component-wise multiplication.

Parameters
vThe vector to multiply.
Returns
The multiplied vector.

◆ Divide() [1/2]

template<class DataType>
Vector Murl::Math::Vector< DataType >::Divide ( DataType  v) const
inline

Get the division (inverse scaling).

Parameters
vThe value to divide.
Returns
The divided vector.

Referenced by Murl::Math::Vector< Real >::operator/().

◆ Divide() [2/2]

template<class DataType>
Vector Murl::Math::Vector< DataType >::Divide ( const Vector< DataType > &  v) const
inline

Get the component-wise division.

Parameters
vThe vector to divide.
Returns
The divided vector.

◆ Cross()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Cross ( const Vector< DataType > &  v) const
inline

Get the cross product.

Parameters
vThe vector to cross.
Returns
The cross product vector.

Referenced by Murl::Math::Vector< Real >::GetBaseNormals(), Murl::Math::Matrix< Real >::LookAt(), and Murl::Math::Sphere< Real >::SetBounding().

◆ Interpolate()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Interpolate ( const Vector< DataType > &  v,
DataType  t 
) const
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
vThe vector to interpolate.
tThe interpolation factor.
Returns
The interpolated vector.

◆ Project()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Project ( const Vector< DataType > &  v) const
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
vThe vector to project from.
Returns
The projected vector.

◆ Min()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Min ( const Vector< DataType > &  v) const
inline

Get the minimum of each component from the vector instance and a given second vector.

Parameters
vThe vector to evaluate the minimum from.
Returns
The minimum vector.

Referenced by Murl::Math::Box< Real >::Set().

◆ Max()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Max ( const Vector< DataType > &  v) const
inline

Get the maximum of each component from the vector instance and a given second vector.

Parameters
vThe vector to evaluate the maximum from.
Returns
The maximum vector.

Referenced by Murl::Math::Box< Real >::Set().

◆ Clamp()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Clamp ( const Vector< DataType > &  min,
const Vector< DataType > &  max 
) const
inline

Clamp each component to the value range given by the min and max vector parameters.

Parameters
minThe component-wise minimum to clamp to.
maxThe component-wise maximum to clamp to.
Returns
The clamped vector.

◆ MinLength()

template<class DataType>
Vector Murl::Math::Vector< DataType >::MinLength ( DataType  v) const
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
vThe minimum length.
Returns
A minimum length vector.

Referenced by Murl::Math::Vector< Real >::MinLengthSelf().

◆ MaxLength()

template<class DataType>
Vector Murl::Math::Vector< DataType >::MaxLength ( DataType  v) const
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
vThe maximum length.
Returns
A maximum length vector.

Referenced by Murl::Math::Vector< Real >::MaxLengthSelf().

◆ ClampLength()

template<class DataType>
Vector Murl::Math::Vector< DataType >::ClampLength ( DataType  min,
DataType  max 
) const
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
minThe minimum length.
maxThe maximum length.
Returns
A clamped vector.

Referenced by Murl::Math::Vector< Real >::ClampLengthSelf().

◆ Abs()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Abs ( ) const
inline

Get a vector containing absolute values for each of the instance's components.

Returns
The resulting vector.

◆ Sgn()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Sgn ( ) const
inline

Get a vector containing component values of either -1, 0 or +1, depending on the instance component's signs.

Returns
The resulting vector.

◆ Invert()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Invert ( ) const
inline

Get the inversion (negation) of the vector instance.

Returns
The inverted vector.

Referenced by Murl::Math::Vector< Real >::operator-().

◆ Normalize()

template<class DataType>
Vector Murl::Math::Vector< DataType >::Normalize ( ) const
inline

Get the normalization of the vector instance.

Normalization retains the direction and sets the length to 1.0.

Returns
The normalized vector.

Referenced by Murl::Math::Vector< Real >::GetBaseNormals(), Murl::Math::Matrix< Real >::LookAt(), and Murl::Math::Vector< Real >::Project().

◆ NormalizeAxis()

template<class DataType>
Vector Murl::Math::Vector< DataType >::NormalizeAxis ( ) const
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.

◆ Dot()

template<class DataType>
DataType Murl::Math::Vector< DataType >::Dot ( const Vector< DataType > &  v) const
inline

Get the dot product of the vector instance and a given second vector.

Parameters
vThe second vector.
Returns
The dot product.

Referenced by Murl::Math::Vector< Real >::Project(), Murl::Math::Vector< Real >::ProjectSelf(), and Murl::Math::Sphere< Real >::SetContaining().

◆ GetLength()

◆ GetSquaredLength()

template<class DataType>
DataType Murl::Math::Vector< DataType >::GetSquaredLength ( ) const
inline

Get the squared length of the vector instance.

Returns
The squared length of the vector.

Referenced by Murl::Math::Sphere< Real >::Include(), Murl::Math::Cone< Real >::IsIntersecting(), Murl::Math::Vector< Real >::Set(), and Murl::Math::Sphere< Real >::SetBounding().

◆ GetAngle2D()

template<class DataType>
DataType Murl::Math::Vector< DataType >::GetAngle2D ( ) const
inline

Get the x/y angle of the vector instance.

Returns
The angle in radians [0 .. 2π].

◆ IsZero() [1/2]

template<class DataType>
Bool Murl::Math::Vector< DataType >::IsZero ( ) const
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< Real >::GetBaseNormals(), and Murl::Math::Vector< Real >::IsZero().

◆ IsZero() [2/2]

template<class DataType>
Bool Murl::Math::Vector< DataType >::IsZero ( DataType  epsilon) const
inline

Check if the vector instance equals the null vector.

Compares all values within a given epsilon range.

Parameters
epsilonThe epsilon to compare.
Returns
true if equals the null vector.

◆ IsZeroPosition() [1/2]

template<class DataType>
Bool Murl::Math::Vector< DataType >::IsZeroPosition ( ) const
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.

Referenced by Murl::Math::Vector< Real >::IsZeroPosition().

◆ IsZeroPosition() [2/2]

template<class DataType>
Bool Murl::Math::Vector< DataType >::IsZeroPosition ( DataType  epsilon) const
inline

Check if the vector instance equals the zero position.

Compares the x, y and z values within a given epsilon range.

Parameters
epsilonThe epsilon to compare.
Returns
true if equals the null vector.

◆ IsEqual() [1/2]

template<class DataType>
Bool Murl::Math::Vector< DataType >::IsEqual ( const Vector< DataType > &  v) const
inline

Check if the vector instance is equal to a given second vector.

Compares all values within the default epsilon range Limits::Epsilon().

Parameters
vThe vector to compare.
Returns
true if equal to the compared vector.

Referenced by Murl::Math::Vector< Real >::IsEqual().

◆ IsEqual() [2/2]

template<class DataType>
Bool Murl::Math::Vector< DataType >::IsEqual ( const Vector< DataType > &  v,
DataType  epsilon 
) const
inline

Check if the vector instance is equal to a given second vector.

Compares all values within a given epsilon range.

Parameters
vThe vector to compare.
epsilonThe epsilon to compare.
Returns
true if equal to the compared vector.

◆ GetBaseNormals()

template<class DataType>
Bool Murl::Math::Vector< DataType >::GetBaseNormals ( Vector< DataType > &  n1,
Vector< DataType > &  n2,
Vector< DataType > &  n3 
) const
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
n1Base vector 1
n2Base vector 2
n3Base vector 3
Returns
true if successful.

◆ ToString()

template<class DataType>
String Murl::Math::Vector< DataType >::ToString ( ) const
inline

Get the string representation of the object.

Returns
The string representation of the object.

◆ GetCount()

template<class DataType>
SInt32 Murl::Math::Vector< DataType >::GetCount ( ) const
inline

Get the number of elements in the object.

Returns
The number of elements in the object.

Friends And Related Function Documentation

◆ operator==

template<class DataType>
bool operator== ( const Vector< DataType > &  lhs,
const Vector< DataType > &  rhs 
)
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
lhsThe left hand side vector to compare.
rhsThe right hand side vector to compare.
Returns
true if all components are exactly the same.

◆ operator!=

template<class DataType>
bool operator!= ( const Vector< DataType > &  lhs,
const Vector< DataType > &  rhs 
)
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
lhsThe left hand side vector to compare.
rhsThe right hand side vector to compare.
Returns
true if all components are not exactly the same.

Member Data Documentation

◆ mComponents

◆ x

◆ y

◆ z

◆ w


The documentation for this class was generated from the following files:
  • murl_app_types.h
  • murl_math_vector.h


Copyright © 2011-2018 Spraylight GmbH.