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

#include <vec3.h>

Public Member Functions

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

Public Attributes

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

Friends

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

Detailed Description

template<class T>
struct vec3< T >

3D vector representation

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

Constructor & Destructor Documentation

◆ vec3() [1/7]

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

default constructor initializes elements with 0

◆ vec3() [2/7]

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

3 element

Parameters
_x
_y
_z

◆ vec3() [3/7]

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

vec4 to vec3 cast

Parameters
a

◆ vec3() [4/7]

template<class T >
vec3< T >::vec3 ( const vec2< T > &  a,
const T &  z 
)
inline

vec2 + T constructor

Parameters
a2D vector
zelement z

◆ vec3() [5/7]

template<class T >
template<typename U >
vec3< T >::vec3 ( const U &  _v)
inlineexplicit

single value constructor

Parameters
_v

◆ vec3() [6/7]

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

copy-constructor

Parameters
v

◆ vec3() [7/7]

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

Member Function Documentation

◆ cross()

template<class T >
vec3< T > vec3< T >::cross ( const vec3< T > &  rhs) const
inline

cross-product

Parameters
rhs
Returns
Examples
vec/TestVec3.cpp.

◆ length()

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

calculates the vectors length (p=2-norm)

\[ \sqrt{\sum x_i} \]

Returns
Examples
vec/TestVec3.cpp.

◆ normalize()

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

returns normalized vector

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

◆ operator vec3< U >()

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

cast operator into new type U

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

◆ operator*=()

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

vector-scalar multiplication

Parameters
rhs
Returns

◆ operator+=()

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

vector-vector addition

Parameters
rhs
Returns

◆ operator-=()

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

vector-vector subtraction

Parameters
rhs
Returns

◆ operator/=()

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

vector-scalar division

Parameters
rhs
Returns

◆ operator=()

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

copy constructor

Parameters
V
Returns

◆ operator[]() [1/2]

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

element access

Parameters
index
Returns

◆ operator[]() [2/2]

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

const element access

Parameters
index
Returns

Friends And Related Function Documentation

◆ operator* [1/3]

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

vector-scalar multiplication

Parameters
lhs
rhs
Returns

◆ operator* [2/3]

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

vector-scalar multiplication

Parameters
lhs
rhs
Returns

◆ operator* [3/3]

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

vector-vector multiplication aka dot-product

Parameters
lhs
rhs
Returns

◆ operator+

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

vector-vector addition

Parameters
lhs
rhs
Returns

◆ operator-

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

vector-vector subtraction

Parameters
lhs
rhs
Returns

◆ operator/ [1/2]

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

vector-scalar division

Parameters
lhs
rhs
Returns

◆ operator/ [2/2]

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

vector-scalar division

Parameters
lhs
rhs
Returns

◆ operator<

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

smaller comparison operator

Parameters
lhs
rhs
Returns

◆ operator<<

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

beautified std::cout operator

Template Parameters
U
Returns

◆ operator==

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

equality comparison

Parameters
lhs
rhs
Returns

◆ operator>

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

bigger comparison operator

Parameters
lhs
rhs
Returns

Member Data Documentation

◆ 

union { ... } vec3< T >::@5

packed data representation

◆ dim

template<class T >
const size_t vec3< T >::dim = 3

dimension of object

◆ x

template<class T >
T vec3< T >::x

◆ y

template<class T >
T vec3< T >::y

◆ z

template<class T >
T vec3< T >::z

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