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, falseT_VEC_VALUE
 
typedef Vec< T, d, trueT_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.
 
 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)
 
 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)
 
 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)
 
 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)
 
 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)
 
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!
 
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.
 
length () const
 Euclidean (2) norm.
 
normalize ()
 Normalize in place and return the 2-norm before normalization.
 
Vec< T, d, falsenormalized () const
 Return a copy of the vector that is normalized.
 
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, falsecopy (T2 *raw, INVALID_WITH_VECTOR_REFERENCE u=(TYPENAME my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
 Initialize vector value using raw memory.
 

Private Attributes

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

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 98 of file Vec.h.

Member Typedef Documentation

◆ T_VEC_REF

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

Definition at line 109 of file Vec.h.

◆ T_VEC_VALUE

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

Definition at line 108 of file Vec.h.

Constructor & Destructor Documentation

◆ Vec() [1/7]

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<refINVALID_WITH_VECTOR_VALUE>::TYPE()) 
)
inlineexplicit

Initialize vector to be reference to plain raw data.

Definition at line 122 of file Vec.h.

◆ Vec() [2/7]

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

Empty constructor (this is invalid for a reference type)

Definition at line 126 of file Vec.h.

◆ Vec() [3/7]

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

Convenience constant vector initialization (valid for any d)

Definition at line 129 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ Vec() [4/7]

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<!refINVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inline

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

Definition at line 134 of file Vec.h.

References TYPENAME, and SeExpr2::Vec< T, d, ref >::x.

◆ Vec() [5/7]

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<!refINVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inline

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

Definition at line 143 of file Vec.h.

References TYPENAME, and SeExpr2::Vec< T, d, ref >::x.

◆ Vec() [6/7]

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<!refINVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inline

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

Definition at line 154 of file Vec.h.

References TYPENAME, and SeExpr2::Vec< T, d, ref >::x.

◆ Vec() [7/7]

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 != refINVALID_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 173 of file Vec.h.

Member Function Documentation

◆ angle()

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 354 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::dot(), SeExpr2::Vec< T, d, ref >::length(), and TYPENAME.

Referenced by SeExpr2::Vec< T, d, ref >::rotateBy().

◆ copy()

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<!refINVALID_WITH_VECTOR_REFERENCE>::TYPE()) 
)
inlinestatic

Initialize vector value using raw memory.

Definition at line 113 of file Vec.h.

◆ cross()

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 338 of file Vec.h.

References TYPENAME, and SeExpr2::Vec< T, d, ref >::x.

Referenced by SeExpr2::Vec< T, d, ref >::rotateBy().

◆ dot()

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

◆ length()

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

◆ length2()

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 204 of file Vec.h.

References SeExpr2::Reducer< T, d >::sum(), and SeExpr2::Vec< T, d, ref >::x.

Referenced by SeExpr2::Vec< T, d, ref >::length(), and SeExpr2::Vec< T, d, ref >::normalize().

◆ 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 214 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::length2(), and SeExpr2::Vec< T, d, ref >::x.

Referenced by SeExpr2::Vec< T, d, ref >::normalized().

◆ 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 227 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::normalize().

◆ operator!=() [1/2]

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 282 of file Vec.h.

◆ operator!=() [2/2]

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 193 of file Vec.h.

◆ operator*() [1/2]

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 313 of file Vec.h.

◆ operator*() [2/2]

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

Definition at line 286 of file Vec.h.

◆ operator*=() [1/2]

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

Definition at line 239 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator*=() [2/2]

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 257 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator+()

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 299 of file Vec.h.

◆ operator+=()

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 245 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator-() [1/2]

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

Definition at line 268 of file Vec.h.

◆ operator-() [2/2]

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 306 of file Vec.h.

◆ operator-=()

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 251 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator/() [1/2]

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 320 of file Vec.h.

◆ operator/() [2/2]

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

Definition at line 292 of file Vec.h.

◆ operator/=() [1/2]

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

Definition at line 233 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator/=() [2/2]

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 263 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator=()

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 180 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator==() [1/2]

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 275 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator==() [2/2]

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 186 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator[]() [1/2]

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

Definition at line 198 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ operator[]() [2/2]

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

Definition at line 201 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::x.

◆ orthogonal()

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 344 of file Vec.h.

References TYPENAME, and SeExpr2::Vec< T, d, ref >::x.

◆ rotateBy()

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 366 of file Vec.h.

References SeExpr2::Vec< T, d, ref >::angle(), SeExpr2::Vec< T, d, ref >::cross(), SeExpr2::Vec< T, d, ref >::dot(), sin(), and TYPENAME.

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

Friends And Related Symbol Documentation

◆ operator*

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

Definition at line 326 of file Vec.h.

Member Data Documentation

◆ x

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: