SeExpr
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
SeExpr2::Vec< T, d, ref > Class Template Reference

#include <Vec.h>

Classes

struct  INVALID_WITH_DIMENSION
 
struct  INVALID_WITH_VECTOR_REFERENCE
 
struct  INVALID_WITH_VECTOR_VALUE
 

Public Types

typedef Vec< T, d, false > T_VEC_VALUE
 
typedef Vec< T, d, true > T_VEC_REF
 

Public Member Functions

 Vec (T *raw, INVALID_WITH_VECTOR_VALUE u=(typename my_enable_if< ref, INVALID_WITH_VECTOR_VALUE >::TYPE()))
 Initialize vector to be reference to plain raw data. More...
 
 Vec (INVALID_WITH_VECTOR_REFERENCE u=(typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
 Empty constructor (this is invalid for a reference type) More...
 
 Vec (T v0, INVALID_WITH_VECTOR_REFERENCE u=(typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
 Convenience constant vector initialization (valid for any d) More...
 
 Vec (T v1, T v2, INVALID_WITH_VECTOR_REFERENCE u=(typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
 Convenience 2 vector initialization (only for d==2) More...
 
 Vec (T v1, T v2, T v3, INVALID_WITH_VECTOR_REFERENCE u=(typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
 Convenience 3 vector initialization (only for d==3) More...
 
 Vec (T v1, T v2, T v3, T v4, INVALID_WITH_VECTOR_REFERENCE u=(typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
 Convenience 4 vector initialization (only for d==4) More...
 
template<class T2 , bool refother>
 Vec (const Vec< T2, d, refother > &other, INVALID_WITH_VECTOR_REFERENCE u=(typename my_enable_if<!ref &&refother!=ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
 Copy construct. Only valid if we are not going to be a reference data! More...
 
template<class T2 , bool refother>
Vecoperator= (const Vec< T2, d, refother > &other)
 
template<class Tother , bool refother>
bool operator== (const Vec< Tother, d, refother > &other) const
 
template<class Tother , bool refother>
bool operator!= (const Vec< Tother, d, refother > &other) const
 
T & operator[] (const int i)
 
const T & operator[] (const int i) const
 
length2 () const
 Square of euclidean (2) norm. More...
 
length () const
 Euclidean (2) norm. More...
 
normalize ()
 Normalize in place and return the 2-norm before normalization. More...
 
Vec< T, d, false > normalized () const
 Return a copy of the vector that is normalized. More...
 
Vecoperator/= (const T val)
 
Vecoperator*= (const T val)
 
template<bool refother>
Vecoperator+= (const Vec< T, d, refother > &other)
 
template<bool refother>
Vecoperator-= (const Vec< T, d, refother > &other)
 
template<bool refother>
Vecoperator*= (const Vec< T, d, refother > &other)
 
template<bool refother>
Vecoperator/= (const Vec< T, d, refother > &other)
 
T_VEC_VALUE operator- () const
 
template<bool refother>
bool operator== (const Vec< T, d, refother > &other) const
 
template<bool refother>
bool operator!= (const Vec< T, d, refother > &other) const
 
T_VEC_VALUE operator* (T s) const
 
T_VEC_VALUE operator/ (T s) const
 
template<bool refother>
T_VEC_VALUE operator+ (const Vec< T, d, refother > &other) const
 
template<bool refother>
T_VEC_VALUE operator- (const Vec< T, d, refother > &other) const
 
template<bool refother>
T_VEC_VALUE operator* (const Vec< T, d, refother > &other) const
 
template<bool refother>
T_VEC_VALUE operator/ (const Vec< T, d, refother > &other) const
 
template<bool refother>
dot (const Vec< T, d, refother > &o) const
 
template<bool refother>
T_VEC_VALUE cross (const Vec< T, 3, refother > &o) const
 
T_VEC_VALUE orthogonal () const
 
template<bool refother>
angle (const Vec< T, 3, refother > &o) const
 
template<bool refother>
T_VEC_VALUE rotateBy (const Vec< T, 3, refother > &axis, T angle) const
 

Static Public Member Functions

template<class T2 >
static Vec< T, d, false > copy (T2 *raw, INVALID_WITH_VECTOR_REFERENCE u=(typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
 Initialize vector value using raw memory. More...
 

Private Attributes

static_if< ref, T *, T[d]>::TYPE x
 internal data (either an explicit arary or a pointer to raw data) More...
 

Friends

T_VEC_VALUE operator* (T s, const Vec &v)
 

Detailed Description

template<class T, int d, bool ref = false>
class SeExpr2::Vec< T, d, ref >

Vec class, generic dimension vector class can also point to data if the template argument ref is true

Definition at line 86 of file Vec.h.

Member Typedef Documentation

template<class T, int d, bool ref = false>
typedef Vec<T, d, true> SeExpr2::Vec< T, d, ref >::T_VEC_REF

Definition at line 97 of file Vec.h.

template<class T, int d, bool ref = false>
typedef Vec<T, d, false> SeExpr2::Vec< T, d, ref >::T_VEC_VALUE

Definition at line 96 of file Vec.h.

Constructor & Destructor Documentation

template<class T, int d, bool ref = false>
SeExpr2::Vec< T, d, ref >::Vec ( T *  raw,
INVALID_WITH_VECTOR_VALUE  u = (typename my_enable_if<ref, INVALID_WITH_VECTOR_VALUE>::TYPE()) 
)
inlineexplicit

Initialize vector to be reference to plain raw data.

Definition at line 108 of file Vec.h.

template<class T, int d, bool ref = false>
SeExpr2::Vec< T, d, ref >::Vec ( INVALID_WITH_VECTOR_REFERENCE  u = (typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE>::TYPE()))
inline

Empty constructor (this is invalid for a reference type)

Definition at line 112 of file Vec.h.

template<class T, int d, bool ref = false>
SeExpr2::Vec< T, d, ref >::Vec ( v0,
INVALID_WITH_VECTOR_REFERENCE  u = (typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inline

Convenience constant vector initialization (valid for any d)

Definition at line 115 of file Vec.h.

template<class T, int d, bool ref = false>
SeExpr2::Vec< T, d, ref >::Vec ( v1,
v2,
INVALID_WITH_VECTOR_REFERENCE  u = (typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inline

Convenience 2 vector initialization (only for d==2)

Definition at line 120 of file Vec.h.

template<class T, int d, bool ref = false>
SeExpr2::Vec< T, d, ref >::Vec ( v1,
v2,
v3,
INVALID_WITH_VECTOR_REFERENCE  u = (typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inline

Convenience 3 vector initialization (only for d==3)

Definition at line 129 of file Vec.h.

template<class T, int d, bool ref = false>
SeExpr2::Vec< T, d, ref >::Vec ( v1,
v2,
v3,
v4,
INVALID_WITH_VECTOR_REFERENCE  u = (typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inline

Convenience 4 vector initialization (only for d==4)

Definition at line 140 of file Vec.h.

template<class T, int d, bool ref = false>
template<class T2 , bool refother>
SeExpr2::Vec< T, d, ref >::Vec ( const Vec< T2, d, refother > &  other,
INVALID_WITH_VECTOR_REFERENCE  u = (typename my_enable_if<!ref && refother != ref, INVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inline

Copy construct. Only valid if we are not going to be a reference data!

Copy construct. Only valid if we are not going to be reference data!

Definition at line 159 of file Vec.h.

Member Function Documentation

template<class T, int d, bool ref = false>
template<bool refother>
T SeExpr2::Vec< T, d, ref >::angle ( const Vec< T, 3, refother > &  o) const
inline

Returns the angle in radians between the current vector and the passed in vector.

Definition at line 337 of file Vec.h.

template<class T, int d, bool ref = false>
template<class T2 >
static Vec<T,d,false> SeExpr2::Vec< T, d, ref >::copy ( T2 *  raw,
INVALID_WITH_VECTOR_REFERENCE  u = (typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inlinestatic

Initialize vector value using raw memory.

Definition at line 101 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::cross ( const Vec< T, 3, refother > &  o) const
inline

Cross product.

Definition at line 321 of file Vec.h.

Referenced by SeExpr2::Vec< double, 3, false >::rotateBy().

template<class T, int d, bool ref = false>
template<bool refother>
T SeExpr2::Vec< T, d, ref >::dot ( const Vec< T, d, refother > &  o) const
inline
template<class T, int d, bool ref = false>
T SeExpr2::Vec< T, d, ref >::length ( ) const
inline

Euclidean (2) norm.

Definition at line 194 of file Vec.h.

Referenced by SeExpr2::Vec< double, 3, false >::angle(), and SeExpr2::rotate().

template<class T, int d, bool ref = false>
T SeExpr2::Vec< T, d, ref >::length2 ( ) const
inline

Square of euclidean (2) norm.

Definition at line 187 of file Vec.h.

Referenced by SeExpr2::Vec< double, 3, false >::length(), and SeExpr2::Vec< double, 3, false >::normalize().

template<class T, int d, bool ref = false>
T SeExpr2::Vec< T, d, ref >::normalize ( )
inline

Normalize in place and return the 2-norm before normalization.

Definition at line 197 of file Vec.h.

Referenced by SeExpr2::Vec< double, 3, false >::normalized().

template<class T, int d, bool ref = false>
Vec<T, d, false> SeExpr2::Vec< T, d, ref >::normalized ( ) const
inline

Return a copy of the vector that is normalized.

Definition at line 210 of file Vec.h.

template<class T, int d, bool ref = false>
template<class Tother , bool refother>
bool SeExpr2::Vec< T, d, ref >::operator!= ( const Vec< Tother, d, refother > &  other) const
inline

Definition at line 178 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
bool SeExpr2::Vec< T, d, ref >::operator!= ( const Vec< T, d, refother > &  other) const
inline

Definition at line 265 of file Vec.h.

template<class T, int d, bool ref = false>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::operator* ( s) const
inline

Definition at line 269 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::operator* ( const Vec< T, d, refother > &  other) const
inline

Definition at line 296 of file Vec.h.

template<class T, int d, bool ref = false>
Vec& SeExpr2::Vec< T, d, ref >::operator*= ( const T  val)
inline

Definition at line 222 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
Vec& SeExpr2::Vec< T, d, ref >::operator*= ( const Vec< T, d, refother > &  other)
inline

Definition at line 240 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::operator+ ( const Vec< T, d, refother > &  other) const
inline

Definition at line 282 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
Vec& SeExpr2::Vec< T, d, ref >::operator+= ( const Vec< T, d, refother > &  other)
inline

Definition at line 228 of file Vec.h.

template<class T, int d, bool ref = false>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::operator- ( ) const
inline

Definition at line 251 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::operator- ( const Vec< T, d, refother > &  other) const
inline

Definition at line 289 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
Vec& SeExpr2::Vec< T, d, ref >::operator-= ( const Vec< T, d, refother > &  other)
inline

Definition at line 234 of file Vec.h.

template<class T, int d, bool ref = false>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::operator/ ( s) const
inline

Definition at line 275 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::operator/ ( const Vec< T, d, refother > &  other) const
inline

Definition at line 303 of file Vec.h.

template<class T, int d, bool ref = false>
Vec& SeExpr2::Vec< T, d, ref >::operator/= ( const T  val)
inline

Definition at line 216 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
Vec& SeExpr2::Vec< T, d, ref >::operator/= ( const Vec< T, d, refother > &  other)
inline

Definition at line 246 of file Vec.h.

template<class T, int d, bool ref = false>
template<class T2 , bool refother>
Vec& SeExpr2::Vec< T, d, ref >::operator= ( const Vec< T2, d, refother > &  other)
inline

Definition at line 166 of file Vec.h.

template<class T, int d, bool ref = false>
template<class Tother , bool refother>
bool SeExpr2::Vec< T, d, ref >::operator== ( const Vec< Tother, d, refother > &  other) const
inline

Definition at line 172 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
bool SeExpr2::Vec< T, d, ref >::operator== ( const Vec< T, d, refother > &  other) const
inline

Definition at line 258 of file Vec.h.

template<class T, int d, bool ref = false>
T& SeExpr2::Vec< T, d, ref >::operator[] ( const int  i)
inline

Definition at line 181 of file Vec.h.

template<class T, int d, bool ref = false>
const T& SeExpr2::Vec< T, d, ref >::operator[] ( const int  i) const
inline

Definition at line 184 of file Vec.h.

template<class T, int d, bool ref = false>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::orthogonal ( ) const
inline

Return a vector orthogonal to the current vector.

Definition at line 327 of file Vec.h.

template<class T, int d, bool ref = false>
template<bool refother>
T_VEC_VALUE SeExpr2::Vec< T, d, ref >::rotateBy ( const Vec< T, 3, refother > &  axis,
angle 
) const
inline

Returns the vector rotated by the angle given in radians about the given axis. (Axis must be normalized)

Definition at line 349 of file Vec.h.

Referenced by SeExpr2::rotate(), and SeExpr2::up().

Friends And Related Function Documentation

template<class T, int d, bool ref = false>
T_VEC_VALUE operator* ( s,
const Vec< T, d, ref > &  v 
)
friend

Definition at line 309 of file Vec.h.

Member Data Documentation

template<class T, int d, bool ref = false>
static_if<ref, T*, T[d]>::TYPE SeExpr2::Vec< T, d, ref >::x
private

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