|
constexpr int | Dimension () const |
| Returns the number of dimensions of the vector. More...
|
|
| Vector ()=default |
| Constructs the vector. Does NOT zero-initialize elements. More...
|
|
| Vector (const Vector &)=default |
|
Vector & | operator= (const Vector &)=default |
|
| Vector (T all) |
| Sets all elements to the same value. More...
|
|
template<class U > |
| Vector (const U *data) |
| Constructs the vector from an array of elements. More...
|
|
template<class T2 , bool Packed2, class = typename std::enable_if<(Dim >= 2> |
| Vector (const Vector< T2, Dim - 1, Packed2 > &rhs) |
| Creates a homogeneous vector by appending a 1. More...
|
|
template<class T2 , bool Packed2> |
| Vector (const Vector< T2, Dim+1, Packed2 > &rhs) |
| Truncates last coordinate of homogenous vector to create non-homogeneous. More...
|
|
template<class H1 , class H2 , class... Scalars, typename std::enable_if< traits::All< traits::IsScalar, H1, H2, Scalars... >::value &&traits::SumDimensions< H1, H2, Scalars... >::value==Dim, int >::type = 0> |
| Vector (H1 h1, H2 h2, Scalars... scalars) |
| Initializes the vector to the given scalar elements. More...
|
|
template<class H1 , class... Mixed, typename std::enable_if< traits::Any< traits::IsVectorOrSwizzle, H1, Mixed... >::value &&traits::SumDimensions< H1, Mixed... >::value==Dim, int >::type = 0> |
| Vector (const H1 &h1, const Mixed &... mixed) |
| Initializes the vector by concatenating given scalar and vector arguments. More...
|
|
template<class... Scalars, typename std::enable_if<((sizeof...(Scalars) > 1> |
Vector & | Set (Scalars... scalars) |
| Sets the vector's elements to the given scalars. More...
|
|
template<class... Mixed, typename std::enable_if<(sizeof...(Mixed) > 0> |
Vector & | Set (const Mixed &... mixed) |
| Sets the vector's elements by concatenating given scalar and vector arguments. More...
|
|
T | operator[] (int idx) const |
| Returns the nth element of the vector. More...
|
|
T & | operator[] (int idx) |
| Returns the nth element of the vector. More...
|
|
T | operator() (int idx) const |
| Returns the nth element of the vector. More...
|
|
T & | operator() (int idx) |
| Returns the nth element of the vector. More...
|
|
const T * | cbegin () const |
| Returns an iterator to the first element. More...
|
|
const T * | begin () const |
| Returns an iterator to the first element. More...
|
|
T * | begin () |
| Returns an iterator to the first element. More...
|
|
const T * | cend () const |
| Returns an iterator to the end of the vector (works like STL). More...
|
|
const T * | end () const |
| Returns an iterator to the end of the vector (works like STL). More...
|
|
T * | end () |
| Returns an iterator to the end of the vector (works like STL). More...
|
|
const T * | Data () const |
| Returns a pointer to the underlying array of elements. More...
|
|
T * | Data () |
| Returns a pointer to the underlying array of elements. More...
|
|
template<class T, int Dim, bool Packed = false>
class mathter::Vector< T, Dim, Packed >
Represents a vector in N-dimensional space.
- Template Parameters
-
T | The scalar type on which the vector is based. You can use builtin floating point or integer types. User-defined types and std::complex may also work, but are not yet officially supported. |
Dim | The dimension of the vector-space. Must be a positive integer. Dynamically sized vectors are not supported yet, but you'll have to use mathter::DYNAMIC to define dynamically sized vectors. |
Packed | Set to true to tightly pack vector elements and avoid padding of the vector struct. Disables SIMD optimizations. |
There is not much extraordinary to vectors, they work as you would expect.
- you can use common vector space airhtmetic
- you have common function like normalization
- you can multiply them with mathter::Matrix from either side
- you can concatenate and swizzle them.
template<class T, int Dim, bool Packed = false>
template<class H1 , class H2 , class... Scalars, typename std::enable_if< traits::All< traits::IsScalar, H1, H2, Scalars... >::value &&traits::SumDimensions< H1, H2, Scalars... >::value==Dim, int >::type = 0>
Initializes the vector to the given scalar elements.
Number of arguments must equal vector dimension. Types of arguments may differ from vector's underlying type, in which case explicit cast is performed.
template<class T, int Dim, bool Packed = false>
template<class H1 , class... Mixed, typename std::enable_if< traits::Any< traits::IsVectorOrSwizzle, H1, Mixed... >::value &&traits::SumDimensions< H1, Mixed... >::value==Dim, int >::type = 0>
Initializes the vector by concatenating given scalar and vector arguments.
Sum of the dimension of arguments must equal vector dimension. Types of arguments may differ from vector's underlying type, in which case explicit cast is performed.
template<class T, int Dim, bool Packed = false>
template<class... Scalars, typename std::enable_if<((sizeof...(Scalars) > 1>
Sets the vector's elements to the given scalars.
Number of arguments must equal vector dimension. Types of arguments may differ from vector's underlying type, in which case explicit cast is performed.
template<class T, int Dim, bool Packed = false>
template<class... Mixed, typename std::enable_if<(sizeof...(Mixed) > 0>
Sets the vector's elements by concatenating given scalar and vector arguments.
Sum of the dimension of arguments must equal vector dimension. Types of arguments may differ from vector's underlying type, in which case explicit cast is performed.