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