KSeExpr 4.0.4.0
KSeExpr::Vec< T, d, ref > Class Template Reference

#include <Vec.h>

Public Types

using T_VEC_VALUE = Vec<T, d, false>
using T_VEC_REF = Vec<T, d, true>

Public Member Functions

 Vec (T *raw)
 Initialize vector to be reference to plain raw data.
 Vec ()
 Empty constructor (this is invalid for a reference type)
 Vec (T v0)
 Convenience constant vector initialization (valid for any d)
 Vec (T v1, T v2)
 Convenience 2 vector initialization (only for d==2)
 Vec (T v1, T v2, T v3)
 Convenience 3 vector initialization (only for d==3)
 Vec (T v1, T v2, T v3, T v4)
 Convenience 4 vector initialization (only for d==4)
template<class T2, bool refother>
 Vec (const Vec< T2, d, refother > &other)
 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, false > normalized () 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, false > copy (T2 *raw)
 Initialize vector value using raw memory.

Private Attributes

static_if< ref, T *, std::array< 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, size_t d, bool ref = false>
class KSeExpr::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 30 of file Vec.h.

Member Typedef Documentation

◆ T_VEC_REF

template<class T, size_t d, bool ref = false>
using KSeExpr::Vec< T, d, ref >::T_VEC_REF = Vec<T, d, true>

Definition at line 37 of file Vec.h.

◆ T_VEC_VALUE

template<class T, size_t d, bool ref = false>
using KSeExpr::Vec< T, d, ref >::T_VEC_VALUE = Vec<T, d, false>

Definition at line 36 of file Vec.h.

Constructor & Destructor Documentation

◆ Vec() [1/7]

template<class T, size_t d, bool ref = false>
KSeExpr::Vec< T, d, ref >::Vec ( T * raw)
inlineexplicit

Initialize vector to be reference to plain raw data.

Definition at line 50 of file Vec.h.

◆ Vec() [2/7]

template<class T, size_t d, bool ref = false>
KSeExpr::Vec< T, d, ref >::Vec ( )
inline

Empty constructor (this is invalid for a reference type)

Definition at line 57 of file Vec.h.

◆ Vec() [3/7]

template<class T, size_t d, bool ref = false>
KSeExpr::Vec< T, d, ref >::Vec ( T v0)
inline

Convenience constant vector initialization (valid for any d)

Definition at line 63 of file Vec.h.

◆ Vec() [4/7]

template<class T, size_t d, bool ref = false>
KSeExpr::Vec< T, d, ref >::Vec ( T v1,
T v2 )
inline

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

Definition at line 71 of file Vec.h.

◆ Vec() [5/7]

template<class T, size_t d, bool ref = false>
KSeExpr::Vec< T, d, ref >::Vec ( T v1,
T v2,
T v3 )
inline

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

Definition at line 80 of file Vec.h.

◆ Vec() [6/7]

template<class T, size_t d, bool ref = false>
KSeExpr::Vec< T, d, ref >::Vec ( T v1,
T v2,
T v3,
T v4 )
inline

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

Definition at line 90 of file Vec.h.

◆ Vec() [7/7]

template<class T, size_t d, bool ref = false>
template<class T2, bool refother>
KSeExpr::Vec< T, d, ref >::Vec ( const Vec< T2, d, refother > & other)
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 105 of file Vec.h.

Member Function Documentation

◆ angle()

template<class T, size_t d, bool ref = false>
template<bool refother>
T KSeExpr::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 317 of file Vec.h.

◆ copy()

template<class T, size_t d, bool ref = false>
template<class T2>
Vec< T, d, false > KSeExpr::Vec< T, d, ref >::copy ( T2 * raw)
inlinestatic

Initialize vector value using raw memory.

Definition at line 40 of file Vec.h.

◆ cross()

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

Cross product.

Definition at line 301 of file Vec.h.

Referenced by KSeExpr::Vec< T, d, false >::rotateBy().

◆ dot()

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

◆ length()

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

Euclidean (2) norm.

Definition at line 153 of file Vec.h.

Referenced by KSeExpr::Vec< T, d, false >::angle(), and KSeExpr::rotate().

◆ length2()

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

Square of euclidean (2) norm.

Definition at line 144 of file Vec.h.

Referenced by KSeExpr::Vec< T, d, false >::length(), and KSeExpr::Vec< T, d, false >::normalize().

◆ normalize()

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

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

Definition at line 159 of file Vec.h.

Referenced by KSeExpr::Vec< T, d, false >::normalized().

◆ normalized()

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

Return a copy of the vector that is normalized.

Definition at line 173 of file Vec.h.

◆ operator!=() [1/2]

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

Definition at line 239 of file Vec.h.

◆ operator!=() [2/2]

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

Definition at line 126 of file Vec.h.

◆ operator*() [1/2]

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

Definition at line 272 of file Vec.h.

◆ operator*() [2/2]

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

Definition at line 244 of file Vec.h.

◆ operator*=() [1/2]

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

Definition at line 188 of file Vec.h.

◆ operator*=() [2/2]

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

Definition at line 209 of file Vec.h.

◆ operator+()

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

Definition at line 258 of file Vec.h.

◆ operator+=()

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

Definition at line 195 of file Vec.h.

◆ operator-() [1/2]

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

Definition at line 223 of file Vec.h.

◆ operator-() [2/2]

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

Definition at line 265 of file Vec.h.

◆ operator-=()

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

Definition at line 202 of file Vec.h.

◆ operator/() [1/2]

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

Definition at line 279 of file Vec.h.

◆ operator/() [2/2]

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

Definition at line 251 of file Vec.h.

◆ operator/=() [1/2]

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

Definition at line 180 of file Vec.h.

◆ operator/=() [2/2]

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

Definition at line 216 of file Vec.h.

◆ operator=()

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

Definition at line 111 of file Vec.h.

◆ operator==() [1/2]

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

Definition at line 231 of file Vec.h.

◆ operator==() [2/2]

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

Definition at line 118 of file Vec.h.

◆ operator[]() [1/2]

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

Definition at line 132 of file Vec.h.

◆ operator[]() [2/2]

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

Definition at line 138 of file Vec.h.

◆ orthogonal()

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

Return a vector orthogonal to the current vector.

Definition at line 307 of file Vec.h.

◆ rotateBy()

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

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

Definition at line 330 of file Vec.h.

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

◆ operator*

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

Definition at line 286 of file Vec.h.

Member Data Documentation

◆ x

template<class T, size_t d, bool ref = false>
static_if<ref,T*,std::array<T,d>>::TYPE KSeExpr::Vec< T, d, ref >::x
private

internal data (either an explicit arary or a pointer to raw data)

Definition at line 33 of file Vec.h.


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