Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C > Class Template Reference

default type for DVALUE_t in templates More...

#include <cVecT.h>

Public Types

typedef TYPE DVALUE_t
 Dimension value type. More...
 
typedef cVecTC< TYPE, _IQTY, _TYPE_C > THIS_t
 

Public Member Functions

TYPEget_T () noexcept
 
const TYPEget_CT () const noexcept
 
const _TYPE_C & get_CR () const noexcept
 
 operator const TYPE * () const noexcept
 
TYPE GetElem (int i) const noexcept
 
TYPE operator[] (int i) const noexcept
 
bool isZero () const noexcept
 
COMPARE_t Compare (const THIS_t &v2) const noexcept
 
bool operator== (const THIS_t &v2) const noexcept
 
bool operator!= (const THIS_t &v2) const noexcept
 
bool IsNear (const THIS_t &v2, TYPE fDist=(TYPE) k_FLT_MIN2) const
 
TYPE get_MagnitudeSq () const noexcept
 
TYPE get_Magnitude () const noexcept
 
_TYPE_C operator- () const
 
_TYPE_C get_Abs () const
 
_TYPE_C GetSum (const THIS_t &v2) const
 
_TYPE_C operator+ (const THIS_t &v2) const
 
_TYPE_C GetDiff (const THIS_t &v2) const
 
_TYPE_C operator- (const THIS_t &v2) const
 
_TYPE_C GetScaled (TYPE nScale) const
 
_TYPE_C operator* (TYPE nScale) const
 
_TYPE_C operator/ (TYPE nScale) const
 
_TYPE_C GetMul (const THIS_t &v2) const
 
_TYPE_C GetDiv (const THIS_t &v2) const
 
TYPE GetDistSq (const THIS_t &v2) const
 
TYPE GetDist (const THIS_t &v2) const
 
TYPE GetDot (const THIS_t &v2) const
 
_TYPE_C get_Normalized () const
 
 operator TYPE * ()
 
TYPERefElem (int i) noexcept
 
TYPEoperator[] (int i)
 
void Set (const THIS_t &v)
 
void SetZero () noexcept
 
TYPE SetNormalized (void) noexcept
 
bool put_Magnitude (TYPE nLength)
 
void SetLerp (const THIS_t &a, const THIS_t &b, DVALUE_t t)
 
const _TYPE_C & operator+= (const THIS_t &v2)
 
const _TYPE_C & operator+= (TYPE n)
 
const _TYPE_C & operator-= (const THIS_t &v2) noexcept
 
const _TYPE_C & operator-= (TYPE n) noexcept
 
void DoScale (TYPE n) noexcept
 
const _TYPE_C & operator*= (TYPE nScale) noexcept
 
const _TYPE_C & operator/= (TYPE nScale)
 
void DoMul (const THIS_t &v2) noexcept
 
_TYPE_C & operator*= (const THIS_t &v2) noexcept
 
void DoDiv (const THIS_t &v2)
 
_TYPE_C & operator/= (const THIS_t &v2)
 

Static Public Member Functions

static TYPE GetDot (const THIS_t &v1, const THIS_t &v2)
 

Static Public Attributes

static const int k_nDim = _IQTY
 

Protected Member Functions

 cVecTC ()
 

Detailed Description

template<typename TYPE, int _IQTY, class _TYPE_C>
class GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >

default type for DVALUE_t in templates

Base class for operations that are generic to vectors of any TYPE or _IQTY. e.g. a 3d point in space. TYPE = the dimension precision. int,float,double. _IQTY = number of dimensions. i.e. 2,3,4 _TYPE_C = the composite derived class that stores the data.

Note
Does NOT allocate actual space for the values !

Member Typedef Documentation

◆ DVALUE_t

template<typename TYPE , int _IQTY, class _TYPE_C >
typedef TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::DVALUE_t

Dimension value type.

◆ THIS_t

template<typename TYPE , int _IQTY, class _TYPE_C >
typedef cVecTC<TYPE, _IQTY, _TYPE_C> GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::THIS_t

Constructor & Destructor Documentation

◆ cVecTC()

template<typename TYPE , int _IQTY, class _TYPE_C >
GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::cVecTC ( )
inlineprotected

Member Function Documentation

◆ Compare()

template<typename TYPE , int _IQTY, class _TYPE_C >
COMPARE_t GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::Compare ( const THIS_t v2) const
inlinenoexcept

◆ DoDiv()

template<typename TYPE , int _IQTY, class _TYPE_C >
void GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::DoDiv ( const THIS_t v2)
inline

◆ DoMul()

template<typename TYPE , int _IQTY, class _TYPE_C >
void GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::DoMul ( const THIS_t v2)
inlinenoexcept

this = this * v2 like: D3DXColorModulate, GetMul()

◆ DoScale()

template<typename TYPE , int _IQTY, class _TYPE_C >
void GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::DoScale ( TYPE  n)
inlinenoexcept

like: D3DXColorScale or D3DXVec4Scale

◆ get_Abs()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::get_Abs ( ) const
inline

◆ get_CR()

template<typename TYPE , int _IQTY, class _TYPE_C >
const _TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::get_CR ( ) const
inlinenoexcept

◆ get_CT()

template<typename TYPE , int _IQTY, class _TYPE_C >
const TYPE* GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::get_CT ( ) const
inlinenoexcept

◆ get_Magnitude()

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::get_Magnitude ( ) const
inlinenoexcept

Vector length = distance to origin. like D3DXVec3Length D3DXQuaternionLength

◆ get_MagnitudeSq()

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::get_MagnitudeSq ( ) const
inlinenoexcept

Vector length Pre-square root. like D3DXVec3LengthSq, D3DXQuaternionLengthSq

◆ get_Normalized()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::get_Normalized ( ) const
inline

Make this vector have a unit length of 1. i.e. get_Magnitude() == 1

◆ get_T()

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE* GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::get_T ( )
inlinenoexcept

◆ GetDiff()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetDiff ( const THIS_t v2) const
inline

= a - b = D3DXVec3Subtract

◆ GetDist()

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetDist ( const THIS_t v2) const
inline

get the distance

◆ GetDistSq()

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetDistSq ( const THIS_t v2) const
inline

get the square of the distance

◆ GetDiv()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetDiv ( const THIS_t v2) const
inline

= a / b

Note
it is not normal to divide a vector by a vector. exists as operator in HLSL but not DX

◆ GetDot() [1/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
static TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetDot ( const THIS_t v1,
const THIS_t v2 
)
inlinestatic

◆ GetDot() [2/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetDot ( const THIS_t v2) const
inline

Dot Product = Angle between vectors. cosine. https://en.wikipedia.org/wiki/Dot_product like D3DXVec3Dot D3DXQuaternionDot D3DXVec4Dot AKA "Inner product" e.g. Calc::ACos( GetDot(v2)) = angle in radians. GetDot(*this) = get_MagnitudeSq() (on self)

Returns
0 to 1, 0=right angle, 1=parallel. Always positive!

◆ GetElem()

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetElem ( int  i) const
inlinenoexcept

get an element of the vector.

◆ GetMul()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetMul ( const THIS_t v2) const
inline

= a * b

Note
it is not normal to multiply a vector by a vector. exists as operator in HLSL but not DX may be used for cQuaternionf ?

◆ GetScaled()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetScaled ( TYPE  nScale) const
inline

= a * nScale

◆ GetSum()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::GetSum ( const THIS_t v2) const
inline

D3DXVec3Add = a + b

◆ IsNear()

template<typename TYPE , int _IQTY, class _TYPE_C >
bool GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::IsNear ( const THIS_t v2,
TYPE  fDist = (TYPE)k_FLT_MIN2 
) const
inline

◆ isZero()

template<typename TYPE , int _IQTY, class _TYPE_C >
bool GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::isZero ( ) const
inlinenoexcept

Are all values in the vector zero?

◆ operator const TYPE *()

template<typename TYPE , int _IQTY, class _TYPE_C >
GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator const TYPE * ( ) const
inlinenoexcept

get a pointer to the vector. this should allow array [x] operators. but with usual 'C' lack of range checking.

◆ operator TYPE *()

template<typename TYPE , int _IQTY, class _TYPE_C >
GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator TYPE * ( )
inline

get a pointer to the vector. this should allow array [x] operators. but with usual 'C' lack of range checking.

◆ operator!=()

template<typename TYPE , int _IQTY, class _TYPE_C >
bool GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator!= ( const THIS_t v2) const
inlinenoexcept

◆ operator*()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator* ( TYPE  nScale) const
inline

= a * nScale

◆ operator*=() [1/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator*= ( const THIS_t v2)
inlinenoexcept

like HLSL, but no D3DX equivalent

◆ operator*=() [2/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
const _TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator*= ( TYPE  nScale)
inlinenoexcept

◆ operator+()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator+ ( const THIS_t v2) const
inline

◆ operator+=() [1/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
const _TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator+= ( const THIS_t v2)
inline

◆ operator+=() [2/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
const _TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator+= ( TYPE  n)
inline

◆ operator-() [1/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator- ( ) const
inline

unary operator = All negative.

◆ operator-() [2/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator- ( const THIS_t v2) const
inline

◆ operator-=() [1/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
const _TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator-= ( const THIS_t v2)
inlinenoexcept

◆ operator-=() [2/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
const _TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator-= ( TYPE  n)
inlinenoexcept

◆ operator/()

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator/ ( TYPE  nScale) const
inline

◆ operator/=() [1/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
_TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator/= ( const THIS_t v2)
inline

like HLSL, but no d3dx equivalent

◆ operator/=() [2/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
const _TYPE_C& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator/= ( TYPE  nScale)
inline

◆ operator==()

template<typename TYPE , int _IQTY, class _TYPE_C >
bool GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator== ( const THIS_t v2) const
inlinenoexcept

◆ operator[]() [1/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator[] ( int  i)
inline

◆ operator[]() [2/2]

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::operator[] ( int  i) const
inlinenoexcept

◆ put_Magnitude()

template<typename TYPE , int _IQTY, class _TYPE_C >
bool GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::put_Magnitude ( TYPE  nLength)
inline

i.e. Magnitude = 1 = normalized.

◆ RefElem()

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE& GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::RefElem ( int  i)
inlinenoexcept

get a changeable reference to an element.

◆ Set()

template<typename TYPE , int _IQTY, class _TYPE_C >
void GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::Set ( const THIS_t v)
inline

◆ SetLerp()

template<typename TYPE , int _IQTY, class _TYPE_C >
void GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::SetLerp ( const THIS_t a,
const THIS_t b,
DVALUE_t  t 
)
inline

change between 2 values. like: D3DXVec3Lerp, D3DXColorLerp or D3DXVec4Lerp t = 0 to 1

◆ SetNormalized()

template<typename TYPE , int _IQTY, class _TYPE_C >
TYPE GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::SetNormalized ( void  )
inlinenoexcept

like D3DXVec3Normalize() and D3DXQuaternionNormalize except it returns the length. NOT the same as D3DXPlaneNormalize

◆ SetZero()

template<typename TYPE , int _IQTY, class _TYPE_C >
void GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::SetZero ( )
inlinenoexcept

Zero all values.

Note
Not the same as zero/neutral quaternion,.

Member Data Documentation

◆ k_nDim

template<typename TYPE , int _IQTY, class _TYPE_C >
const int GrayLib::cVecTC< TYPE, _IQTY, _TYPE_C >::k_nDim = _IQTY
static

The documentation for this class was generated from the following file: