Two dimensional (x, y) vector. More...
#include <gz/math/Vector2.hh>
Public Member Functions | |
constexpr | Vector2 () |
Default Constructor. More... | |
constexpr | Vector2 (const T &_x, const T &_y) |
Constructor. More... | |
Vector2 (const Vector2< T > &_v)=default | |
Copy constructor. More... | |
~Vector2 ()=default | |
Destructor. More... | |
Vector2 | Abs () const |
Get the absolute value of the vector. More... | |
T | AbsDot (const Vector2< T > &_v) const |
Return the absolute dot product of this vector and another vector. This is similar to the Dot function, except the absolute value of each component of the vector is used. More... | |
void | Correct () |
Corrects any nan values. More... | |
double | Distance (const Vector2 &_pt) const |
Calc distance to the given point. More... | |
T | Dot (const Vector2< T > &_v) const |
Get the dot product of this vector and _v. More... | |
bool | Equal (const Vector2 &_v, const T &_tol) const |
Equality test with tolerance. More... | |
bool | IsFinite () const |
See if a point is finite (e.g., not nan) More... | |
T | Length () const |
Returns the length (magnitude) of the vector. More... | |
T | Max () const |
Get the maximum value in the vector. More... | |
void | Max (const Vector2< T > &_v) |
Set this vector's components to the maximum of itself and the passed in vector. More... | |
T | Min () const |
Get the minimum value in the vector. More... | |
void | Min (const Vector2< T > &_v) |
Set this vector's components to the minimum of itself and the passed in vector. More... | |
void | Normalize () |
Normalize the vector length. More... | |
Vector2 | Normalized () const |
Returns a normalized vector. More... | |
bool | operator!= (const Vector2 &_v) const |
Not equal to operator. More... | |
const Vector2 | operator* (const Vector2 &_v) const |
Multiplication operators. More... | |
const Vector2 | operator* (T _v) const |
Multiplication operators. More... | |
const Vector2 & | operator*= (const Vector2 &_v) |
Multiplication assignment operator. More... | |
const Vector2 & | operator*= (T _v) |
Multiplication assignment operator. More... | |
Vector2< T > | operator+ (const T _s) const |
Addition operators. More... | |
Vector2 | operator+ (const Vector2 &_v) const |
Addition operator. More... | |
const Vector2< T > & | operator+= (const T _s) |
Addition assignment operator. More... | |
const Vector2 & | operator+= (const Vector2 &_v) |
Addition assignment operator. More... | |
Vector2 | operator- () const |
Negation operator. More... | |
Vector2< T > | operator- (const T _s) const |
Subtraction operators. More... | |
Vector2 | operator- (const Vector2 &_v) const |
Subtraction operator. More... | |
const Vector2 & | operator-= (const Vector2 &_v) |
Subtraction assignment operator. More... | |
const Vector2< T > & | operator-= (T _s) |
Subtraction assignment operator. More... | |
const Vector2 | operator/ (const Vector2 &_v) const |
Division operator. More... | |
const Vector2 | operator/ (T _v) const |
Division operator. More... | |
const Vector2 & | operator/= (const Vector2 &_v) |
Division operator. More... | |
const Vector2 & | operator/= (T _v) |
Division operator. More... | |
bool | operator< (const Vector2< T > &_pt) const |
Less than operator. More... | |
Vector2 & | operator= (const Vector2 &_v)=default |
Assignment operator. More... | |
const Vector2 & | operator= (T _v) |
Assignment operator. More... | |
bool | operator== (const Vector2 &_v) const |
Equal to operator. More... | |
T & | operator[] (const std::size_t _index) |
Array subscript operator. More... | |
T | operator[] (const std::size_t _index) const |
Const-qualified array subscript operator. More... | |
Vector2 | Round () |
Round to near whole number, return the result. More... | |
Vector2 | Rounded () const |
Get a rounded version of this vector. More... | |
void | Set (T _x, T _y) |
Set the contents of the vector. More... | |
T | SquaredLength () const |
Returns the square of the length (magnitude) of the vector. More... | |
T | Sum () const |
Return the sum of the values. More... | |
T & | X () |
Return a mutable x value. More... | |
T | X () const |
Return the x value. More... | |
void | X (const T &_v) |
Set the x value. More... | |
T & | Y () |
Return a mutable y value. More... | |
T | Y () const |
Return the y value. More... | |
void | Y (const T &_v) |
Set the y value. More... | |
Static Public Attributes | |
static const Vector2 & | NaN = detail::gVector2NaN<T> |
math::Vector2(NaN, NaN, NaN) More... | |
static const Vector2< T > & | One = detail::gVector2One<T> |
math::Vector2(1, 1) More... | |
static const Vector2< T > & | Zero = detail::gVector2Zero<T> |
math::Vector2(0, 0) More... | |
Detailed Description
template<typename T>
class gz::math::Vector2< T >
Two dimensional (x, y) vector.
Constructor & Destructor Documentation
◆ Vector2() [1/3]
|
inlineconstexpr |
Default Constructor.
Referenced by Vector2< T >::Abs(), Vector2< T >::operator*(), Vector2< T >::operator+(), Vector2< T >::operator-(), and Vector2< T >::operator/().
◆ Vector2() [2/3]
|
inlineconstexpr |
Constructor.
- Parameters
-
[in] _x value along x [in] _y value along y
◆ Vector2() [3/3]
◆ ~Vector2()
|
default |
Destructor.
Member Function Documentation
◆ Abs()
|
inline |
Get the absolute value of the vector.
- Returns
- a vector with positive elements
References Vector2< T >::Vector2().
◆ AbsDot()
|
inline |
Return the absolute dot product of this vector and another vector. This is similar to the Dot function, except the absolute value of each component of the vector is used.
result = abs(x1 * x2) + abs(y1 * y2)
- Parameters
-
[in] _v The vector
- Returns
- The absolute dot product
◆ Correct()
|
inline |
Corrects any nan values.
References std::isfinite().
◆ Distance()
|
inline |
Calc distance to the given point.
- Parameters
-
[in] _pt The point to measure to
- Returns
- the distance
◆ Dot()
|
inline |
Get the dot product of this vector and _v.
- Parameters
-
[in] _v the vector
- Returns
- The dot product
Referenced by Triangle< T >::Contains().
◆ Equal()
|
inline |
Equality test with tolerance.
- Parameters
-
[in] _v the vector to compare to [in] _tol equality tolerance.
- Returns
- true if the elements of the vectors are equal within the tolerence specified by _tol.
Referenced by Vector2< T >::operator==().
◆ IsFinite()
|
inline |
See if a point is finite (e.g., not nan)
- Returns
- true if finite, false otherwise
References std::isfinite().
◆ Length()
|
inline |
Returns the length (magnitude) of the vector.
- Returns
- The length
References Vector2< T >::SquaredLength().
Referenced by Vector2< T >::Normalize().
◆ Max() [1/2]
|
inline |
◆ Max() [2/2]
|
inline |
Set this vector's components to the maximum of itself and the passed in vector.
- Parameters
-
[in] _v the maximum clamping vector
References std::max().
◆ Min() [1/2]
|
inline |
◆ Min() [2/2]
|
inline |
Set this vector's components to the minimum of itself and the passed in vector.
- Parameters
-
[in] _v the minimum clamping vector
References std::min().
◆ Normalize()
|
inline |
Normalize the vector length.
References Vector2< T >::Length().
Referenced by Vector2< T >::Normalized().
◆ Normalized()
|
inline |
◆ operator!=()
|
inline |
Not equal to operator.
- Returns
- true if elements are of diffent values (tolerence 1e-6)
◆ operator*() [1/2]
Multiplication operators.
- Parameters
-
[in] _v the vector
- Returns
- the result
References Vector2< T >::Vector2().
◆ operator*() [2/2]
|
inline |
Multiplication operators.
- Parameters
-
[in] _v the scaling factor
- Returns
- a scaled vector
References Vector2< T >::Vector2().
◆ operator*=() [1/2]
Multiplication assignment operator.
- Remarks
- this is an element wise multiplication
- Parameters
-
[in] _v the vector
- Returns
- this
◆ operator*=() [2/2]
|
inline |
Multiplication assignment operator.
- Parameters
-
[in] _v the scaling factor
- Returns
- a scaled vector
◆ operator+() [1/2]
|
inline |
Addition operators.
- Parameters
-
[in] _s the scalar addend
- Returns
- sum vector
◆ operator+() [2/2]
Addition operator.
- Parameters
-
[in] _v vector to add
- Returns
- sum vector
References Vector2< T >::Vector2().
◆ operator+=() [1/2]
|
inline |
Addition assignment operator.
- Parameters
-
[in] _s scalar addend
- Returns
- this
◆ operator+=() [2/2]
Addition assignment operator.
- Parameters
-
[in] _v the vector to add
◆ operator-() [1/3]
|
inline |
◆ operator-() [2/3]
|
inline |
Subtraction operators.
- Parameters
-
[in] _s the scalar subtrahend
- Returns
- difference vector
◆ operator-() [3/3]
Subtraction operator.
- Parameters
-
[in] _v the vector to substract
- Returns
- the subtracted vector
References Vector2< T >::Vector2().
◆ operator-=() [1/2]
Subtraction assignment operator.
- Parameters
-
[in] _v the vector to substract
- Returns
- this
◆ operator-=() [2/2]
|
inline |
Subtraction assignment operator.
- Parameters
-
[in] _s scalar subtrahend
- Returns
- this
◆ operator/() [1/2]
Division operator.
- Remarks
- this is an element wise division
- Parameters
-
[in] _v a vector
- Returns
- a result
References Vector2< T >::Vector2().
◆ operator/() [2/2]
|
inline |
◆ operator/=() [1/2]
Division operator.
- Remarks
- this is an element wise division
- Parameters
-
[in] _v a vector
- Returns
- this
◆ operator/=() [2/2]
|
inline |
Division operator.
- Parameters
-
[in] _v the divisor
- Returns
- a vector
◆ operator<()
|
inline |
Less than operator.
- Parameters
-
[in] _pt Vector to compare.
- Returns
- True if this vector's first or second value is less than the given vector's first or second value.
◆ operator=() [1/2]
Assignment operator.
- Parameters
-
[in] _v a value for x and y element
- Returns
- this
◆ operator=() [2/2]
|
inline |
Assignment operator.
- Parameters
-
[in] _v the value for x and y element
- Returns
- this
◆ operator==()
|
inline |
Equal to operator.
- Parameters
-
[in] _v the vector to compare to
- Returns
- true if the elements of the 2 vectors are equal within a tolerence (1e-6)
References Vector2< T >::Equal().
◆ operator[]() [1/2]
|
inline |
Array subscript operator.
- Parameters
-
[in] _index The index, where 0 == x and 1 == y. The index is clamped to the range [0,1].
References gz::math::clamp(), gz::math::GZ_ONE_SIZE_T, and gz::math::GZ_ZERO_SIZE_T.
◆ operator[]() [2/2]
|
inline |
Const-qualified array subscript operator.
- Parameters
-
[in] _index The index, where 0 == x and 1 == y. The index is clamped to the range [0,1].
References gz::math::clamp(), gz::math::GZ_ONE_SIZE_T, and gz::math::GZ_ZERO_SIZE_T.
◆ Round()
|
inline |
Round to near whole number, return the result.
- Returns
- the result
References std::nearbyint().
Referenced by Vector2< T >::Rounded().
◆ Rounded()
|
inline |
◆ Set()
|
inline |
Set the contents of the vector.
- Parameters
-
[in] _x value along x [in] _y value along y
Referenced by MassMatrix3< T >::PrincipalAxesOffset().
◆ SquaredLength()
|
inline |
Returns the square of the length (magnitude) of the vector.
- Returns
- The squared length
Referenced by Vector2< T >::Length(), and MassMatrix3< T >::PrincipalAxesOffset().
◆ Sum()
|
inline |
Return the sum of the values.
- Returns
- the sum
◆ X() [1/3]
|
inline |
Return a mutable x value.
- Returns
- Value of the X component.
◆ X() [2/3]
|
inline |
Return the x value.
- Returns
- Value of the X component.
Referenced by Line2< T >::CrossProduct(), Line2< T >::Intersect(), and Line2< T >::Within().
◆ X() [3/3]
|
inline |
Set the x value.
- Parameters
-
[in] _v Value for the x component.
◆ Y() [1/3]
|
inline |
Return a mutable y value.
- Returns
- Value of the Y component.
◆ Y() [2/3]
|
inline |
Return the y value.
- Returns
- Value of the Y component.
Referenced by Line2< T >::CrossProduct(), Line2< T >::Intersect(), and Line2< T >::Within().
◆ Y() [3/3]
|
inline |
Set the y value.
- Parameters
-
[in] _v Value for the y component.
Member Data Documentation
◆ NaN
|
static |
math::Vector2(NaN, NaN, NaN)
◆ One
|
static |
math::Vector2(1, 1)
◆ Zero
|
static |
math::Vector2(0, 0)
The documentation for this class was generated from the following file: