vmmlib  1.13.0
Templatized C++ vector and matrix math library
vmml::vector< M, T > Class Template Reference
+ Collaboration diagram for vmml::vector< M, T >:

Public Types

typedef T value_type
 
typedef T * iterator
 
typedef const T * const_iterator
 
typedef std::reverse_iterator< iterator > reverse_iterator
 
typedef std::reverse_iterator< const_iterator > const_reverse_iterator
 

Public Member Functions

 vector (const T &a)
 
 vector (const T &x, const T &y)
 
 vector (const T &x, const T &y, const T &z)
 
 vector (const T &x, const T &y, const T &z, const T &w)
 
template<typename TT >
 vector (const vector< M-1, TT > &vector_, T last_, typename std::enable_if< M==4, TT >::type *=nullptr)
 
 vector (const T *values)
 
template<typename TT >
 vector (const vector< 3, TT > &source_, typename std::enable_if< M==4, TT >::type *=nullptr)
 
template<typename TT >
 vector (const vector< 4, TT > &source_, typename std::enable_if< M==3, TT >::type *=nullptr)
 
template<typename U >
 vector (const vector< M, U > &source_)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
 operator T * ()
 
 operator const T * () const
 
T & operator() (size_t index)
 
const T & operator() (size_t index) const
 
T & at (size_t index)
 
const T & at (size_t index) const
 
T & x ()
 
T & y ()
 
T & z ()
 
T & w ()
 
const T & x () const
 
const T & y () const
 
const T & z () const
 
const T & w () const
 
T & r ()
 
T & g ()
 
T & b ()
 
T & a ()
 
const T & r () const
 
const T & g () const
 
const T & b () const
 
const T & a () const
 
bool operator== (const vector &other) const
 
bool operator!= (const vector &other) const
 
bool equals (const vector &other, T tolerance=std::numeric_limits< T >::epsilon()) const
 
bool operator< (const vector &other) const
 
operator= (T filler)
 
vectoroperator= (const vector &other)
 
template<typename U >
void operator= (const vector< M, U > &other)
 
vector operator* (const vector &other) const
 
vector operator/ (const vector &other) const
 
vector operator+ (const vector &other) const
 
vector operator- (const vector &other) const
 
void operator*= (const vector &other)
 
void operator/= (const vector &other)
 
void operator+= (const vector &other)
 
void operator-= (const vector &other)
 
vector operator* (const T other) const
 
vector operator/ (const T other) const
 
vector operator+ (const T other) const
 
vector operator- (const T other) const
 
void operator*= (const T other)
 
void operator/= (const T other)
 
void operator+= (const T other)
 
void operator-= (const T other)
 
vector operator- () const
 
const vectornegate ()
 
void set (T a)
 
template<size_t N>
void set (const vector< N, T > &v)
 
void set (T x, T y)
 
void set (T x, T y, T z)
 
void set (T x, T y, T z, T w)
 
template<typename input_iterator_t >
void iter_set (input_iterator_t begin_, input_iterator_t end_)
 
template<typename TT >
vector< M, T > & cross (const vector< M, TT > &b, typename std::enable_if< M==3, TT >::type *=nullptr)
 
dot (const vector &other) const
 
normalize ()
 
void set_random (int seed=-1)
 
length () const
 
squared_length () const
 
distance (const vector &other) const
 
squared_distance (const vector &other) const
 
product () const
 
template<typename TT >
vector< 3, T > & rotate (T theta, vector< M, TT > axis, typename std::enable_if< M==3, TT >::type *=nullptr)
 
template<size_t N, size_t O>
vector< N, T > get_sub_vector (typename std::enable_if< M >=N+O >::type *=nullptr) const
 
template<size_t N, size_t O>
void set_sub_vector (const vector< N, T > &sub, typename std::enable_if< M >=N+O >::type *=nullptr)
 Set the sub vector of the given length at the given offset. More...
 
template<typename TT >
vector< 3, T > project_point_onto_sphere (const vector< 3, TT > &point, typename std::enable_if< M==4, TT >::type *=nullptr) const
 
template<typename TT >
distance_to_sphere (const vector< 3, TT > &point, typename std::enable_if< M==4, TT >::type *=nullptr) const
 
template<typename TT >
distance_to_plane (const vector< 3, TT > &point, typename std::enable_if< M==4, TT >::type *=nullptr) const
 
template<typename TT >
vector< 3, T > project_point_onto_plane (const vector< 3, TT > &point, typename std::enable_if< M==4, TT >::type *=nullptr) const
 
size_t find_min_index () const
 
size_t find_max_index () const
 
T & find_min ()
 
T & find_max ()
 
const T & find_min () const
 
const T & find_max () const
 
void clamp (const T &min=0.0, const T &max=1.0)
 
bool is_unit_vector () const
 
void perturb (T perturbation=0.0001)
 
void sqrt_elementwise ()
 
double norm () const
 
void reciprocal ()
 
void reciprocal_safe ()
 
template<typename TT >
void cast_from (const vector< M, TT > &other)
 
size_t nnz () const
 

Static Public Member Functions

static size_t size ()
 
Convenience presets for 3 and 4 component vectors
static vector< M, T > zero ()
 
static vector< M, T > forward ()
 
static vector< M, T > backward ()
 
static vector< M, T > up ()
 
static vector< M, T > down ()
 
static vector< M, T > left ()
 
static vector< M, T > right ()
 
static vector< M, T > unitX ()
 
static vector< M, T > unitY ()
 
static vector< M, T > unitZ ()
 

Public Attributes

array [M]
 storage
 

Static Public Attributes

static const size_t DIMENSION = M
 

Friends

std::ostream & operator<< (std::ostream &os, const vector &vector_)
 

Detailed Description

template<size_t M, typename T>
class vmml::vector< M, T >

Definition at line 45 of file types.hpp.

Member Function Documentation

template<size_t M, typename T >
template<size_t N, size_t O>
vector< N, T > vmml::vector< M, T >::get_sub_vector ( typename std::enable_if< M >  = N + O,
::type *  = nullptr 
) const
Returns
the sub vector of the given length at the given offset.

Definition at line 1015 of file vector.hpp.

References vmml::vector< M, T >::array.

template<size_t M, typename T >
T vmml::vector< M, T >::product ( ) const
inline
Returns
the product of all elements of this vector

Definition at line 945 of file vector.hpp.

template<size_t M, typename T>
template<size_t N, size_t O>
void vmml::vector< M, T >::set_sub_vector ( const vector< N, T > &  sub,
typename std::enable_if< M >  = N + O,
::type *  = nullptr 
)

Set the sub vector of the given length at the given offset.

Definition at line 1023 of file vector.hpp.

References vmml::vector< M, T >::array.


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