|
Jet
v1.3.3
|
4-D vector class. More...
#include <jet/vector4.h>
Public Member Functions | |
| constexpr | Vector () |
| Constructs default vector (0, 0, 0, 0). More... | |
| constexpr | Vector (T x_, T y_, T z_, T w_) |
Constructs vector with given parameters x_, y_, z_, and w_. More... | |
| constexpr | Vector (const Vector3< T > &v, T w_) |
| Constructs vector with a 3-D vector (x, y, and z) and a scalar (w). More... | |
| template<typename U > | |
| Vector (const std::initializer_list< U > &lst) | |
| Constructs vector with initializer list. More... | |
| constexpr | Vector (const Vector &v) |
| Copy constructor. More... | |
| void | set (T s) |
Set both x, y, z, and w components to s. More... | |
| void | set (T x, T y, T z, T w) |
| Set x, y, z, and w components with given parameters. More... | |
| void | set (const Vector< T, 3 > &pt, T z) |
Set x, y, z, and w components with pt.x, pt.y, z, and w. More... | |
| template<typename U > | |
| void | set (const std::initializer_list< U > &lst) |
| Set x, y, z, and w components with given initializer list. More... | |
| void | set (const Vector &v) |
Set x, y, z, and w with other vector v. More... | |
| void | setZero () |
| Set all x, y, z, and w to zero. More... | |
| void | normalize () |
| Normalizes this vector. More... | |
| Vector | add (T v) const |
| Computes this + (v, v, v, v). More... | |
| Vector | add (const Vector &v) const |
| Computes this + (v.x, v.y, v.z, v.w). More... | |
| Vector | sub (T v) const |
| Computes this - (v, v, v, v). More... | |
| Vector | sub (const Vector &v) const |
| Computes this - (v.x, v.y, v.z, v.w). More... | |
| Vector | mul (T v) const |
| Computes this * (v, v, v, v). More... | |
| Vector | mul (const Vector &v) const |
| Computes this * (v.x, v.y, v.z, v.w). More... | |
| Vector | div (T v) const |
| Computes this / (v, v, v, v). More... | |
| Vector | div (const Vector &v) const |
| Computes this / (v.x, v.y, v.z, v.w). More... | |
| T | dot (const Vector &v) const |
| Computes dot product. More... | |
| Vector | rsub (T v) const |
| Computes (v, v, v, v) - this. More... | |
| Vector | rsub (const Vector &v) const |
| Computes (v.x, v.y, v.z, v.w) - this. More... | |
| Vector | rdiv (T v) const |
| Computes (v, v, v, v) / this. More... | |
| Vector | rdiv (const Vector &v) const |
| Computes (v.x, v.y, v.z, v.w) / this. More... | |
| void | iadd (T v) |
| Computes this += (v, v, v, v). More... | |
| void | iadd (const Vector &v) |
| Computes this += (v.x, v.y, v.z, v.w). More... | |
| void | isub (T v) |
| Computes this -= (v, v, v, v). More... | |
| void | isub (const Vector &v) |
| Computes this -= (v.x, v.y, v.z, v.w). More... | |
| void | imul (T v) |
| Computes this *= (v, v, v, v). More... | |
| void | imul (const Vector &v) |
| Computes this *= (v.x, v.y, v.z, v.w). More... | |
| void | idiv (T v) |
| Computes this /= (v, v, v, v). More... | |
| void | idiv (const Vector &v) |
| Computes this /= (v.x, v.y, v.z, v.w). More... | |
| const T & | at (size_t i) const |
Returns const reference to the i -th element of the vector. More... | |
| T & | at (size_t i) |
Returns reference to the i -th element of the vector. More... | |
| T | sum () const |
| Returns the sum of all the components (i.e. x + y + z + w). More... | |
| T | avg () const |
| Returns the average of all the components. More... | |
| T | min () const |
| Returns the minimum value among x, y, z, and w. More... | |
| T | max () const |
| Returns the maximum value among x, y, z, and w. More... | |
| T | absmin () const |
| Returns the absolute minimum value among x, y, z, and w. More... | |
| T | absmax () const |
| Returns the absolute maximum value among x, y, z, and w. More... | |
| size_t | dominantAxis () const |
| Returns the index of the dominant axis. More... | |
| size_t | subminantAxis () const |
| Returns the index of the subminant axis. More... | |
| Vector | normalized () const |
| Returns normalized vector. More... | |
| T | length () const |
| Returns the length of the vector. More... | |
| T | lengthSquared () const |
| Returns the squared length of the vector. More... | |
| T | distanceTo (const Vector &other) const |
| Returns the distance to the other vector. More... | |
| T | distanceSquaredTo (const Vector &other) const |
| Returns the squared distance to the other vector. More... | |
| template<typename U > | |
| Vector< U, 4 > | castTo () const |
| Returns a vector with different value type. More... | |
| bool | isEqual (const Vector &other) const |
Returns true if other is the same as this vector. More... | |
| bool | isSimilar (const Vector &other, T epsilon=std::numeric_limits< T >::epsilon()) const |
Returns true if other is similar to this vector. More... | |
| T & | operator[] (size_t i) |
Returns reference to the i -th element of the vector. More... | |
| const T & | operator[] (size_t i) const |
Returns const reference to the i -th element of the vector. More... | |
| template<typename U > | |
| Vector & | operator= (const std::initializer_list< U > &lst) |
| Set x and y components with given initializer list. More... | |
| Vector & | operator= (const Vector &v) |
Set x and y with other vector v. More... | |
| Vector & | operator+= (T v) |
| Computes this += (v, v, v, v) More... | |
| Vector & | operator+= (const Vector &v) |
| Computes this += (v.x, v.y, v.z, v.w) More... | |
| Vector & | operator-= (T v) |
| Computes this -= (v, v, v, v) More... | |
| Vector & | operator-= (const Vector &v) |
| Computes this -= (v.x, v.y, v.z, v.w) More... | |
| Vector & | operator*= (T v) |
| Computes this *= (v, v, v, v) More... | |
| Vector & | operator*= (const Vector &v) |
| Computes this *= (v.x, v.y, v.z, v.w) More... | |
| Vector & | operator/= (T v) |
| Computes this /= (v, v, v, v) More... | |
| Vector & | operator/= (const Vector &v) |
| Computes this /= (v.x, v.y, v.z, v.w) More... | |
| bool | operator== (const Vector &v) const |
Returns true if other is the same as this vector. More... | |
| bool | operator!= (const Vector &v) const |
Returns true if other is the not same as this vector. More... | |
Public Attributes | |
| T | x |
| X (or the first) component of the vector. More... | |
| T | y |
| Y (or the second) component of the vector. More... | |
| T | z |
| Z (or the third) component of the vector. More... | |
| T | w |
| W (or the fourth) component of the vector. More... | |
4-D vector class.
This class defines simple 4-D vector data.
| T | - Type of the element |
|
inlineconstexpr |
Constructs default vector (0, 0, 0, 0).
|
inlineconstexpr |
Constructs vector with given parameters x_, y_, z_, and w_.
|
inlineconstexpr |
Constructs vector with a 3-D vector (x, y, and z) and a scalar (w).
| jet::Vector< T, 4 >::Vector | ( | const std::initializer_list< U > & | lst | ) |
Constructs vector with initializer list.
|
inlineconstexpr |
Copy constructor.
| T jet::Vector< T, 4 >::absmax | ( | ) | const |
Returns the absolute maximum value among x, y, z, and w.
| T jet::Vector< T, 4 >::absmin | ( | ) | const |
Returns the absolute minimum value among x, y, z, and w.
| Vector jet::Vector< T, 4 >::add | ( | const Vector< T, 4 > & | v | ) | const |
Computes this + (v.x, v.y, v.z, v.w).
| Vector jet::Vector< T, 4 >::add | ( | T | v | ) | const |
Computes this + (v, v, v, v).
| T& jet::Vector< T, 4 >::at | ( | size_t | i | ) |
Returns reference to the i -th element of the vector.
| const T& jet::Vector< T, 4 >::at | ( | size_t | i | ) | const |
Returns const reference to the i -th element of the vector.
| T jet::Vector< T, 4 >::avg | ( | ) | const |
Returns the average of all the components.
Returns a vector with different value type.
| T jet::Vector< T, 4 >::distanceSquaredTo | ( | const Vector< T, 4 > & | other | ) | const |
Returns the squared distance to the other vector.
| T jet::Vector< T, 4 >::distanceTo | ( | const Vector< T, 4 > & | other | ) | const |
Returns the distance to the other vector.
| Vector jet::Vector< T, 4 >::div | ( | const Vector< T, 4 > & | v | ) | const |
Computes this / (v.x, v.y, v.z, v.w).
| Vector jet::Vector< T, 4 >::div | ( | T | v | ) | const |
Computes this / (v, v, v, v).
| size_t jet::Vector< T, 4 >::dominantAxis | ( | ) | const |
Returns the index of the dominant axis.
| T jet::Vector< T, 4 >::dot | ( | const Vector< T, 4 > & | v | ) | const |
Computes dot product.
| void jet::Vector< T, 4 >::iadd | ( | const Vector< T, 4 > & | v | ) |
Computes this += (v.x, v.y, v.z, v.w).
| void jet::Vector< T, 4 >::iadd | ( | T | v | ) |
Computes this += (v, v, v, v).
| void jet::Vector< T, 4 >::idiv | ( | const Vector< T, 4 > & | v | ) |
Computes this /= (v.x, v.y, v.z, v.w).
| void jet::Vector< T, 4 >::idiv | ( | T | v | ) |
Computes this /= (v, v, v, v).
| void jet::Vector< T, 4 >::imul | ( | const Vector< T, 4 > & | v | ) |
Computes this *= (v.x, v.y, v.z, v.w).
| void jet::Vector< T, 4 >::imul | ( | T | v | ) |
Computes this *= (v, v, v, v).
| bool jet::Vector< T, 4 >::isEqual | ( | const Vector< T, 4 > & | other | ) | const |
Returns true if other is the same as this vector.
| bool jet::Vector< T, 4 >::isSimilar | ( | const Vector< T, 4 > & | other, |
| T | epsilon = std::numeric_limits< T >::epsilon() |
||
| ) | const |
Returns true if other is similar to this vector.
| void jet::Vector< T, 4 >::isub | ( | const Vector< T, 4 > & | v | ) |
Computes this -= (v.x, v.y, v.z, v.w).
| void jet::Vector< T, 4 >::isub | ( | T | v | ) |
Computes this -= (v, v, v, v).
| T jet::Vector< T, 4 >::length | ( | ) | const |
Returns the length of the vector.
| T jet::Vector< T, 4 >::lengthSquared | ( | ) | const |
Returns the squared length of the vector.
| T jet::Vector< T, 4 >::max | ( | ) | const |
Returns the maximum value among x, y, z, and w.
| T jet::Vector< T, 4 >::min | ( | ) | const |
Returns the minimum value among x, y, z, and w.
| Vector jet::Vector< T, 4 >::mul | ( | const Vector< T, 4 > & | v | ) | const |
Computes this * (v.x, v.y, v.z, v.w).
| Vector jet::Vector< T, 4 >::mul | ( | T | v | ) | const |
Computes this * (v, v, v, v).
| void jet::Vector< T, 4 >::normalize | ( | ) |
Normalizes this vector.
| Vector jet::Vector< T, 4 >::normalized | ( | ) | const |
Returns normalized vector.
| bool jet::Vector< T, 4 >::operator!= | ( | const Vector< T, 4 > & | v | ) | const |
Returns true if other is the not same as this vector.
| Vector& jet::Vector< T, 4 >::operator*= | ( | const Vector< T, 4 > & | v | ) |
Computes this *= (v.x, v.y, v.z, v.w)
| Vector& jet::Vector< T, 4 >::operator*= | ( | T | v | ) |
Computes this *= (v, v, v, v)
| Vector& jet::Vector< T, 4 >::operator+= | ( | const Vector< T, 4 > & | v | ) |
Computes this += (v.x, v.y, v.z, v.w)
| Vector& jet::Vector< T, 4 >::operator+= | ( | T | v | ) |
Computes this += (v, v, v, v)
| Vector& jet::Vector< T, 4 >::operator-= | ( | const Vector< T, 4 > & | v | ) |
Computes this -= (v.x, v.y, v.z, v.w)
| Vector& jet::Vector< T, 4 >::operator-= | ( | T | v | ) |
Computes this -= (v, v, v, v)
| Vector& jet::Vector< T, 4 >::operator/= | ( | const Vector< T, 4 > & | v | ) |
Computes this /= (v.x, v.y, v.z, v.w)
| Vector& jet::Vector< T, 4 >::operator/= | ( | T | v | ) |
Computes this /= (v, v, v, v)
| Vector& jet::Vector< T, 4 >::operator= | ( | const std::initializer_list< U > & | lst | ) |
Set x and y components with given initializer list.
| Vector& jet::Vector< T, 4 >::operator= | ( | const Vector< T, 4 > & | v | ) |
Set x and y with other vector v.
| bool jet::Vector< T, 4 >::operator== | ( | const Vector< T, 4 > & | v | ) | const |
Returns true if other is the same as this vector.
| T& jet::Vector< T, 4 >::operator[] | ( | size_t | i | ) |
Returns reference to the i -th element of the vector.
| const T& jet::Vector< T, 4 >::operator[] | ( | size_t | i | ) | const |
Returns const reference to the i -th element of the vector.
| Vector jet::Vector< T, 4 >::rdiv | ( | const Vector< T, 4 > & | v | ) | const |
Computes (v.x, v.y, v.z, v.w) / this.
| Vector jet::Vector< T, 4 >::rdiv | ( | T | v | ) | const |
Computes (v, v, v, v) / this.
| Vector jet::Vector< T, 4 >::rsub | ( | const Vector< T, 4 > & | v | ) | const |
Computes (v.x, v.y, v.z, v.w) - this.
| Vector jet::Vector< T, 4 >::rsub | ( | T | v | ) | const |
Computes (v, v, v, v) - this.
| void jet::Vector< T, 4 >::set | ( | const std::initializer_list< U > & | lst | ) |
Set x, y, z, and w components with given initializer list.
| void jet::Vector< T, 4 >::set | ( | const Vector< T, 4 > & | v | ) |
Set x, y, z, and w with other vector v.
| void jet::Vector< T, 4 >::set | ( | const Vector< T, 3 > & | pt, |
| T | z | ||
| ) |
Set x, y, z, and w components with pt.x, pt.y, z, and w.
| void jet::Vector< T, 4 >::set | ( | T | s | ) |
Set both x, y, z, and w components to s.
| void jet::Vector< T, 4 >::set | ( | T | x, |
| T | y, | ||
| T | z, | ||
| T | w | ||
| ) |
Set x, y, z, and w components with given parameters.
| void jet::Vector< T, 4 >::setZero | ( | ) |
Set all x, y, z, and w to zero.
| Vector jet::Vector< T, 4 >::sub | ( | const Vector< T, 4 > & | v | ) | const |
Computes this - (v.x, v.y, v.z, v.w).
| Vector jet::Vector< T, 4 >::sub | ( | T | v | ) | const |
Computes this - (v, v, v, v).
| size_t jet::Vector< T, 4 >::subminantAxis | ( | ) | const |
Returns the index of the subminant axis.
| T jet::Vector< T, 4 >::sum | ( | ) | const |
Returns the sum of all the components (i.e. x + y + z + w).
| T jet::Vector< T, 4 >::w |
W (or the fourth) component of the vector.
| T jet::Vector< T, 4 >::x |
X (or the first) component of the vector.
| T jet::Vector< T, 4 >::y |
Y (or the second) component of the vector.
| T jet::Vector< T, 4 >::z |
Z (or the third) component of the vector.
1.8.18