CoreComponents 3.0.0
A Modern C++ Toolkit
|
Algebraic vector. More...
#include <cc/Vector>
Public Types | |
using | Item = T |
Item type. | |
Static Public Attributes | |
static constexpr int | Count = N |
Number of components. | |
Standard Iterators | |
using | value_type = Item |
Item value type. | |
using | size_type = long |
Type of the container capacity. | |
using | iterator = ArrayIterator<Vector, 1> |
Value iterator. | |
using | const_iterator = ArrayIterator<const Vector, 1> |
Readonly value iterator. | |
using | reverse_iterator = ArrayIterator<Vector, -1> |
Reverse value iterator. | |
using | const_reverse_iterator = ArrayIterator<const Vector, -1> |
Readonly reverse value iterator. | |
iterator | begin () |
Return iterator pointing to the first item (if any) | |
iterator | end () |
Return iterator pointing behind the last item | |
const_iterator | begin () const |
Return readonly iterator pointing to the first item (if any) | |
const_iterator | cbegin () const |
Return readonly iterator pointing to the first item (if any) | |
const_iterator | end () const |
Return readonly iterator pointing behind the last item | |
const_iterator | cend () const |
Return readonly iterator pointing behind the last item | |
reverse_iterator | rbegin () |
Return reverse iterator pointing to the last item (if any) | |
reverse_iterator | rend () |
Return reverse iterator pointing before the first item | |
const_reverse_iterator | rbegin () const |
Return readonly reverse iterator pointing to the last item (if any) | |
const_reverse_iterator | crbegin () const |
Return readonly reverse iterator pointing to the last item (if any) | |
const_reverse_iterator | rend () const |
Return reverse iterator pointing before the first item | |
const_reverse_iterator | crend () const |
Return reverse iterator pointing before the first item | |
Construction and Assignment | |
Vector () | |
Create a null vector. | |
Vector (std::initializer_list< T > l) | |
Create a vector with initial components l. | |
Vector (T b) | |
Create a vector with all components initialized with b. | |
Item Access | |
T & | at (int i) |
Get reference to component at i. | |
const T & | at (int i) const |
Get constant reference to component at i. | |
T & | operator[] (int i) |
Get reference to component at i. | |
const T & | operator[] (int i) const |
Get constant reference to component at i. | |
T | x () const |
Get value of the first component. | |
T | y () const |
Get value of the second component. | |
T | z () const |
Get value of the third component. | |
static constexpr int | count () |
Get the number of components. | |
Global Operations | |
Vector | operator- () const |
Negate all components of the vector. | |
Vector & | operator+= (const Vector &b) |
Add component-vise vector b. | |
Vector & | operator-= (const Vector &b) |
Substract component-vise vector b. | |
Vector & | operator*= (const Vector &b) |
Multiply component-vise vector b. | |
Vector & | operator/= (const Vector &b) |
Divide component-vise vector b. | |
Vector & | operator*= (T b) |
Multiply each component with b. | |
Vector & | operator/= (T b) |
Divide each component with b. | |
Vector | operator+ (const Vector &b) const |
Add vector b and return result. | |
Vector | operator- (const Vector &b) const |
Substract vector b and return result. | |
Vector | operator* (const Vector &b) const |
Component-wise multiply vector b and return result. | |
Vector | operator/ (const Vector &b) const |
Component-wise divide vector b and return result. | |
Vector | operator* (T b) const |
Multiply each component with b and return result. | |
Vector | operator/ (T b) const |
Divide each component with b and return result. | |
Vector | round () const |
Get a copy of this vector with each component rounded. | |
Vector | ceil () const |
Get a copy of this vector with each component rounded upwards. | |
T | min () const |
Get the smallest component value. | |
T | max () const |
Get the greatest component value. | |
T | absPow2 () const |
Magnitude squared. | |
T | abs () const |
Magnitude. | |
T | avg () const |
Compute the average of all component values. | |
Comparism Operators | |
bool | operator== (const Vector &b) const |
Equal to operator. | |
std::strong_ordering | operator<=> (const Vector &b) const |
Ordering operator. | |
Algebraic vector.
T | Item type |
N | Number of components |
using Item = T |
Item type.
using value_type = Item |
Item value type.
using size_type = long |
Type of the container capacity.
using iterator = ArrayIterator<Vector, 1> |
Value iterator.
using const_iterator = ArrayIterator<const Vector, 1> |
Readonly value iterator.
using reverse_iterator = ArrayIterator<Vector, -1> |
Reverse value iterator.
using const_reverse_iterator = ArrayIterator<const Vector, -1> |
Readonly reverse value iterator.
Vector | ( | ) |
Create a null vector.
Vector | ( | std::initializer_list< T > | l | ) |
Create a vector with initial components l.
Vector | ( | T | b | ) |
Create a vector with all components initialized with b.
|
staticconstexpr |
Get the number of components.
T & at | ( | int | i | ) |
Get reference to component at i.
const T & at | ( | int | i | ) | const |
Get constant reference to component at i.
T & operator[] | ( | int | i | ) |
Get reference to component at i.
const T & operator[] | ( | int | i | ) | const |
Get constant reference to component at i.
T x | ( | ) | const |
Get value of the first component.
T y | ( | ) | const |
Get value of the second component.
T z | ( | ) | const |
Get value of the third component.
Vector operator- | ( | ) | const |
Negate all components of the vector.
Add component-vise vector b.
Substract component-vise vector b.
Multiply component-vise vector b.
Divide component-vise vector b.
Vector & operator*= | ( | T | b | ) |
Multiply each component with b.
Vector & operator/= | ( | T | b | ) |
Divide each component with b.
Add vector b and return result.
Substract vector b and return result.
Component-wise multiply vector b and return result.
Component-wise divide vector b and return result.
Vector operator* | ( | T | b | ) | const |
Multiply each component with b and return result.
Vector operator/ | ( | T | b | ) | const |
Divide each component with b and return result.
Vector round | ( | ) | const |
Get a copy of this vector with each component rounded.
Vector ceil | ( | ) | const |
Get a copy of this vector with each component rounded upwards.
T min | ( | ) | const |
Get the smallest component value.
T max | ( | ) | const |
Get the greatest component value.
T absPow2 | ( | ) | const |
Magnitude squared.
T abs | ( | ) | const |
Magnitude.
T avg | ( | ) | const |
Compute the average of all component values.
iterator begin | ( | ) |
Return iterator pointing to the first item (if any)
iterator end | ( | ) |
Return iterator pointing behind the last item
const_iterator begin | ( | ) | const |
Return readonly iterator pointing to the first item (if any)
const_iterator cbegin | ( | ) | const |
Return readonly iterator pointing to the first item (if any)
const_iterator end | ( | ) | const |
Return readonly iterator pointing behind the last item
const_iterator cend | ( | ) | const |
Return readonly iterator pointing behind the last item
reverse_iterator rbegin | ( | ) |
Return reverse iterator pointing to the last item (if any)
reverse_iterator rend | ( | ) |
Return reverse iterator pointing before the first item
const_reverse_iterator rbegin | ( | ) | const |
Return readonly reverse iterator pointing to the last item (if any)
const_reverse_iterator crbegin | ( | ) | const |
Return readonly reverse iterator pointing to the last item (if any)
const_reverse_iterator rend | ( | ) | const |
Return reverse iterator pointing before the first item
const_reverse_iterator crend | ( | ) | const |
Return reverse iterator pointing before the first item
bool operator== | ( | const Vector< T, N > & | b | ) | const |
Equal to operator.
std::strong_ordering operator<=> | ( | const Vector< T, N > & | b | ) | const |
Ordering operator.
|
staticconstexpr |
Number of components.