Fixed-size math vector class template with generic operations. More...
#include <vector.h>

Public Types | |
| using | Pod_type = Vector_struct<T, DIM> |
| POD class corresponding to this vector. More... | |
| using | storage_type = Vector_struct<T, DIM> |
| Storage class used by this vector. More... | |
| using | value_type = T |
| Element type. More... | |
| using | size_type = Size |
| Size type, unsigned. More... | |
| using | difference_type = Difference |
| Difference type, signed. More... | |
| using | pointer = T * |
| Mutable pointer to element. More... | |
| using | const_pointer = const T * |
| Const pointer to element. More... | |
| using | reference = T & |
| Mutable reference to element. More... | |
| using | const_reference = const T & |
| Const reference to element. More... | |
Public Member Functions | |
| T * | begin () |
| Returns the pointer to the first vector element. More... | |
| const T * | begin () const |
| Returns the pointer to the first vector element. More... | |
| T * | end () |
| Returns the past-the-end pointer. More... | |
| const T * | end () const |
| Returns the past-the-end pointer. More... | |
| Vector () | |
| The default constructor leaves the vector elements uninitialized. More... | |
| Vector (const Vector<T, DIM> &vec)=default | |
| Default copy constructor. More... | |
| Vector (const Vector_struct<T, DIM> &vec) | |
| Constructor from underlying storage type. More... | |
| template<typename Iterator> | |
| Vector (From_iterator_tag, Iterator p) | |
Constructor requires the mi::math::FROM_ITERATOR tag as first argument and initializes the vector elements with the first DIM elements from the sequence starting at the iterator p. More... | |
| template<typename T2> | |
| Vector (T2 const (&array)[DIM]) | |
Constructor initializes the vector elements from an array of dimension DIM. More... | |
| template<typename T2> | |
| Vector (const Vector<T2, DIM> &other) | |
| Template constructor that allows explicit conversions from other vectors with assignment compatible element value type. More... | |
| template<typename T2> | |
| Vector (const Vector_struct<T2, DIM> &other) | |
| Template constructor that allows explicit conversions from underlying storage type with assignment compatible element value type. More... | |
| Vector (T v1, T v2) | |
Dedicated constructor, for dimension 2 only, that initializes the vector elements from the two elements (v1,v2). More... | |
| Vector (T v1, T v2, T v3) | |
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1,v2,v3). More... | |
| Vector (T v1, const Vector<T, 2> &v2) | |
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1,v2.x,v2.y). More... | |
| Vector (const Vector<T, 2> &v1, T v2) | |
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1.x,v1.y,v2). More... | |
| Vector (T v1, T v2, T v3, T v4) | |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2,v3,v4). More... | |
| Vector (T v1, T v2, const Vector<T, 2> &v3) | |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2,v3.x,v3.y). More... | |
| Vector (T v1, const Vector<T, 2> &v2, T v3) | |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2.x,v2.y,v3). More... | |
| Vector (const Vector<T, 2> &v1, T v2, T v3) | |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v2,v3). More... | |
| Vector (const Vector<T, 2> &v1, const Vector<T, 2> &v2) | |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v2.x,v2.y). More... | |
| Vector (T v1, const Vector<T, 3> &v2) | |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2.x,v2.y,v2.z). More... | |
| Vector (const Vector<T, 3> &v1, T v2) | |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v1.z,v2). More... | |
| Vector (const Color_struct &color) | |
| Dedicated constructor, for dimension 4 only, that initializes the vector elements from a color interpreted as a vector (r,g,b,a). More... | |
| Vector & | operator= (const Vector &other)=default |
| Assignment. More... | |
| Vector & | operator= (T s) |
Assignment from a scalar, setting all elements to s. More... | |
| Vector & | operator= (const Color_struct &color) |
| Assignment, for dimension 4 only, that assigns color interpreted as a vector (r,g,b,a) to this vector. More... | |
| T & | operator[] (Size i) |
Accesses the i-th vector element. More... | |
| const T & | operator[] (Size i) const |
Accesses the i-th vector element. More... | |
| const T & | get (Size i) const |
Returns the i-th vector element. More... | |
| void | set (Size i, T value) |
Sets the i-th vector element to value. More... | |
| bool | normalize () |
| Normalizes this vector to unit length. More... | |
| bool | operator== (Vector<T, DIM> rhs) const |
Returns true if lhs is elementwise equal to rhs. More... | |
| bool | operator!= (Vector<T, DIM> rhs) const |
Returns true if lhs is elementwise not equal to rhs. More... | |
| bool | operator< (Vector<T, DIM> rhs) const |
Returns true if lhs is lexicographically less than rhs. More... | |
| bool | operator<= (Vector<T, DIM> rhs) const |
Returns true if lhs is lexicographically less than or equal to rhs. More... | |
| bool | operator> (Vector<T, DIM> rhs) const |
Returns true if lhs is lexicographically greater than rhs. More... | |
| bool | operator>= (Vector<T, DIM> rhs) const |
Returns true if lhs is lexicographically greater than or equal to rhs. More... | |
Static Public Member Functions | |
| static constexpr Size | size () |
| Constant size of the vector. More... | |
| static constexpr Size | max_size () |
| Constant maximum size of the vector. More... | |
Public Attributes | |
| T | elements [DIM] |
| coordinates. More... | |
Static Public Attributes | |
| static constexpr Size | DIMENSION = DIM |
| Constant dimension of the vector. More... | |
| static constexpr Size | SIZE = DIM |
| Constant size of the vector. More... | |
Fixed-size math vector class template with generic operations.
This class template provides array-like storage for DIM many values of an arithmetic type T. Several functions and arithmetic operators support the work with vectors.
An instantiation of the vector class template is a model of the STL container concept. It provides random access to its elements and corresponding random access iterators.
The template parameters have the following requirements:
+ - * / == != < > <= >= sqrt() .Depending on the dimension DIM, the mi::math::Vector class template offers element access through the conventional data members named x, y, z, and w. Assuming a vector vec of suitable dimension, the following expressions are valid
vec.x; equivalent to vec[0] and available if 1 <= DIM <= 4.vec.y; equivalent to vec[1] and available if 2 <= DIM <= 4.vec.z; equivalent to vec[2] and available if 3 <= DIM <= 4.vec.w; equivalent to vec[3] and available if 4 <= DIM <= 4.These data members allow users to access elements, as illustrated in the following example:
#include <mi/math/vector.h>