philsupertramp/game-math
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Friends | List of all members
vec4< T > Struct Template Reference

#include <vec4.h>

Public Member Functions

 vec4 ()
 
 vec4 (const T &_x, const T &_y, const T &_z, const T &_w)
 
 vec4 (const T &v)
 
 vec4 (const T *v)
 
 vec4 (const vec4< T > &v)
 
template<typename V >
 vec4 (const V &v, const T &_w)
 
float length () const
 
vec4< T > normalize () const
 
sum () const
 
vec4< T > & operator+= (const vec4< T > &rhs)
 
vec4< T > & operator-= (const vec4< T > &rhs)
 
vec4< T > & operator*= (const T &rhs)
 
vec4< T > & operator/= (const T &rhs)
 
constexpr vec4< T > & operator= (vec4< T > const &V)
 
T & operator[] (const int &index)
 
const T & operator[] (const int &index) const
 
template<typename U >
 operator vec4< U > ()
 

Public Attributes

union {
   struct {
      T   x
 
      T   y
 
      T   z
 
      T   w
 
   } 
 
}; 
 representation of packed data More...
 
const size_t dim = 4
 dimension of object More...
 

Friends

vec4< T > operator+ (vec4< T > lhs, const vec4< T > &rhs)
 
vec4< T > operator- (vec4< T > lhs, const vec4< T > &rhs)
 
vec4< T > operator* (vec4< T > lhs, const T &rhs)
 
vec4< T > operator* (const T &lhs, vec4< T > rhs)
 
vec4< T > operator* (vec4< T > lhs, const vec4< T > &rhs)
 
vec4< T > operator/ (vec4< T > lhs, const T &rhs)
 
bool operator== (const vec4< T > &lhs, const vec4< T > &rhs)
 
template<class U >
std::ostream & operator<< (std::ostream &, const vec4< U > &)
 

Detailed Description

template<class T>
struct vec4< T >

4D-vector implementation

Template Parameters
T
Examples
TestUtils.cpp, mat/TestMat4.cpp, vec/TestVec3.cpp, and vec/TestVec4.cpp.

Constructor & Destructor Documentation

◆ vec4() [1/6]

template<class T >
vec4< T >::vec4 ( )
inline

empty constructor initializes object with element value 0

◆ vec4() [2/6]

template<class T >
vec4< T >::vec4 ( const T &  _x,
const T &  _y,
const T &  _z,
const T &  _w 
)
inline

4-element constructor

Parameters
_x
_y
_z
_w

◆ vec4() [3/6]

template<class T >
vec4< T >::vec4 ( const T &  v)
inlineexplicit

◆ vec4() [4/6]

template<class T >
vec4< T >::vec4 ( const T *  v)
inlineexplicit

data array constructor

Parameters
v

◆ vec4() [5/6]

template<class T >
vec4< T >::vec4 ( const vec4< T > &  v)
inline

copy constructor

Parameters
v

◆ vec4() [6/6]

template<class T >
template<typename V >
vec4< T >::vec4 ( const V &  v,
const T &  _w 
)
inline

Member Function Documentation

◆ length()

template<class T >
float vec4< T >::length ( ) const
inline

Getter for vector length

Returns
Examples
vec/TestVec4.cpp.

◆ normalize()

template<class T >
vec4< T > vec4< T >::normalize ( ) const
inline

Getter for normalized vector

Returns
Examples
TestUtils.cpp, and vec/TestVec4.cpp.

◆ operator vec4< U >()

template<class T >
template<typename U >
vec4< T >::operator vec4< U > ( )
inlineexplicit

cast operator into new type

Template Parameters
U
Returns
vec4<U>(vec4<T>)

◆ operator*=()

template<class T >
vec4< T > & vec4< T >::operator*= ( const T &  rhs)
inline

vector-scalar multiplication

Parameters
rhs
Returns

◆ operator+=()

template<class T >
vec4< T > & vec4< T >::operator+= ( const vec4< T > &  rhs)
inline

vector-vector addition

Parameters
rhs
Returns

◆ operator-=()

template<class T >
vec4< T > & vec4< T >::operator-= ( const vec4< T > &  rhs)
inline

vector-vector subtraction

Parameters
rhs
Returns

◆ operator/=()

template<class T >
vec4< T > & vec4< T >::operator/= ( const T &  rhs)
inline

vector-scalar division

Parameters
rhs
Returns

◆ operator=()

template<class T >
constexpr vec4< T > & vec4< T >::operator= ( vec4< T > const &  V)
inlineconstexpr

const copy constructor

Parameters
V
Returns

◆ operator[]() [1/2]

template<class T >
T & vec4< T >::operator[] ( const int &  index)
inline

element access

Parameters
index
Returns

◆ operator[]() [2/2]

template<class T >
const T & vec4< T >::operator[] ( const int &  index) const
inline

const element access

Parameters
index
Returns

◆ sum()

template<class T >
T vec4< T >::sum ( ) const
inline

Friends And Related Function Documentation

◆ operator* [1/3]

template<class T >
vec4< T > operator* ( const T &  lhs,
vec4< T >  rhs 
)
friend

scalar-vector multiplication

Parameters
lhs
rhs
Returns

◆ operator* [2/3]

template<class T >
vec4< T > operator* ( vec4< T >  lhs,
const T &  rhs 
)
friend

vector-constant multiplication

Parameters
lhs
rhs
Returns

◆ operator* [3/3]

template<class T >
vec4< T > operator* ( vec4< T >  lhs,
const vec4< T > &  rhs 
)
friend

Dot product implementation

Parameters
lhs
rhs
Returns

◆ operator+

template<class T >
vec4< T > operator+ ( vec4< T >  lhs,
const vec4< T > &  rhs 
)
friend

vector-vector addition

Parameters
lhs
rhs
Returns

◆ operator-

template<class T >
vec4< T > operator- ( vec4< T >  lhs,
const vec4< T > &  rhs 
)
friend

vector-vector subtraction

Parameters
lhs
rhs
Returns

◆ operator/

template<class T >
vec4< T > operator/ ( vec4< T >  lhs,
const T &  rhs 
)
friend

vector-scalar division

Parameters
lhs
rhs
Returns

◆ operator<<

template<class T >
template<class U >
std::ostream & operator<< ( std::ostream &  ,
const vec4< U > &   
)
friend

beautified std::cout operator

Template Parameters
U
Returns

◆ operator==

template<class T >
bool operator== ( const vec4< T > &  lhs,
const vec4< T > &  rhs 
)
friend

equality comparison

Parameters
lhs
rhs
Returns

Member Data Documentation

◆ 

union { ... } vec4< T >::@9

representation of packed data

◆ dim

template<class T >
const size_t vec4< T >::dim = 4

dimension of object

◆ w

template<class T >
T vec4< T >::w

◆ x

template<class T >
T vec4< T >::x

◆ y

template<class T >
T vec4< T >::y

◆ z

template<class T >
T vec4< T >::z

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