Fixed-size math vector class template with generic operations. More...
Public Types | |
typedef Vector_struct< T, DIM > | Pod_type |
POD class corresponding to this vector. More... |
|
typedef Vector_struct< T, DIM > | storage_type |
Storage class used by this vector. More... |
|
typedef T | value_type |
Element type. More... |
|
typedef Size | size_type |
Size type, unsigned. More... |
|
typedef Difference | difference_type |
Difference type, signed. More... |
|
typedef T * | pointer |
Mutable pointer to element. More... |
|
typedef const T * | const_pointer |
Const pointer to element. More... |
|
typedef T & | reference |
Mutable reference to element. More... |
|
typedef const T & | const_reference |
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_struct< T, DIM > &vec) | |
Constructor from underlying storage type. More... |
|
Vector (T v) | |
Constructor initializes all vector elements to the value v . 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... |
|
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) |
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_proxy_< T, DIM > rhs) const |
Returns true if lhs is elementwise equal to rhs . More... |
|
bool | operator!= (Vector_proxy_< T, DIM > rhs) const |
Returns true if lhs is elementwise not equal to rhs . More... |
|
bool | operator< (Vector_proxy_< T, DIM > rhs) const |
Returns true if lhs is lexicographically less than rhs . More... |
|
bool | operator<= (Vector_proxy_< T, DIM > rhs) const |
Returns true if lhs is lexicographically less than or equal to rhs . More... |
|
bool | operator> (Vector_proxy_< T, DIM > rhs) const |
Returns true if lhs is lexicographically greater than rhs . More... |
|
bool | operator>= (Vector_proxy_< T, DIM > rhs) const |
Returns true if lhs is lexicographically greater than or equal to rhs . More... |
|
Static Public Member Functions | |
static Size | size () |
Constant size of the vector. More... |
|
static Size | max_size () |
Constant maximum size of the vector. More... |
|
Static Public Attributes | |
static const Size | DIMENSION = DIM |
Constant dimension of the vector. More... |
|
static const Size | SIZE = DIM |
Constant size of the vector. More... |
|
Additional Inherited Members | |
Public Attributes inherited from mi::math::Vector_struct< T, DIM > | |
T | elements [DIM] |
coordinates. 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>
typedef const T* mi::math::Vector< T, DIM >::const_pointer |
Const pointer to element.
typedef const T& mi::math::Vector< T, DIM >::const_reference |
Const reference to element.
typedef Difference mi::math::Vector< T, DIM >::difference_type |
Difference type, signed.
typedef Vector_struct<T,DIM> mi::math::Vector< T, DIM >::Pod_type |
POD class corresponding to this vector.
typedef T* mi::math::Vector< T, DIM >::pointer |
Mutable pointer to element.
typedef T& mi::math::Vector< T, DIM >::reference |
Mutable reference to element.
typedef Size mi::math::Vector< T, DIM >::size_type |
Size type, unsigned.
typedef Vector_struct<T,DIM> mi::math::Vector< T, DIM >::storage_type |
Storage class used by this vector.
typedef T mi::math::Vector< T, DIM >::value_type |
Element type.
|
inline |
The default constructor leaves the vector elements uninitialized.
|
inline |
Constructor from underlying storage type.
|
inlineexplicit |
Constructor initializes all vector elements to the value v
.
|
inline |
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
.
Iterator
must be a model of an input iterator. The value type of Iterator
must be assignment compatible with the vector elements type T
.
An example:
|
inlineexplicit |
Constructor initializes the vector elements from an array
of dimension DIM
.
The value type T2
of the array
must be assignment compatible with the vector elements type T
.
An example:
|
inlineexplicit |
Template constructor that allows explicit conversions from other vectors with assignment compatible element value type.
|
inline |
Dedicated constructor, for dimension 2 only, that initializes the vector elements from the two elements (v1,v2).
DIM == 2
|
inline |
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1,v2,v3).
DIM == 3
|
inline |
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1,v2.x,v2.y).
DIM == 3
|
inline |
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elements (v1.x,v1.y,v2).
DIM == 3
|
inline |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2,v3,v4).
DIM == 4
|
inline |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2,v3.x,v3.y).
DIM == 4
|
inline |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2.x,v2.y,v3).
DIM == 4
|
inline |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v2,v3).
DIM == 4
|
inline |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v2.x,v2.y).
DIM == 4
|
inline |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1,v2.x,v2.y,v2.z).
DIM == 4
|
inline |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four elements (v1.x,v1.y,v1.z,v2).
DIM == 4
|
inlineexplicit |
Dedicated constructor, for dimension 4 only, that initializes the vector elements from a color interpreted as a vector (r,g,b,a).
DIM == 4
|
inline |
Returns the pointer to the first vector element.
|
inline |
Returns the pointer to the first vector element.
|
inline |
|
inline |
|
inline |
Returns the i-th
vector element.
i
< size()
|
inlinestatic |
Constant maximum size of the vector.
|
inline |
Normalizes this vector to unit length.
Returns false
if normalization fails because the vector norm is zero, and true
otherwise. This vector remains unchanged if normalization failed.
Uses an unqualified call to sqrt
(...) on the vector element type.
|
inline |
Returns true
if lhs
is elementwise not equal to rhs
.
|
inline |
Returns true
if lhs
is lexicographically less than rhs
.
|
inline |
Returns true
if lhs
is lexicographically less than or equal to rhs
.
|
inline |
Assignment.
|
inline |
Assignment from a scalar, setting all elements to s
.
|
inline |
Assignment, for dimension 4 only, that assigns color interpreted as a vector (r,g,b,a) to this vector.
DIM == 4
|
inline |
Returns true
if lhs
is elementwise equal to rhs
.
|
inline |
Returns true
if lhs
is lexicographically greater than rhs
.
|
inline |
Returns true
if lhs
is lexicographically greater than or equal to rhs
.
|
inline |
Accesses the i-th
vector element.
i
< size()
|
inline |
Accesses the i-th
vector element.
i
< size()
|
inline |
Sets the i-th
vector element to value
.
i
< size()
|
inlinestatic |
Constant size of the vector.
|
static |
Constant dimension of the vector.
|
static |
Constant size of the vector.