T Generic x, y, z, w vector. More...
#include <gz/math/Vector4.hh>
Public Member Functions | |
constexpr | Vector4 () |
Constructor. | |
constexpr | Vector4 (const T &_x, const T &_y, const T &_z, const T &_w) |
Constructor with component values. | |
Vector4 | Abs () const |
Get the absolute value of the vector. | |
T | AbsDot (const Vector4< 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. | |
void | Correct () |
Corrects any nan values. | |
T | Distance (const Vector4< T > &_pt) const |
Calc distance to the given point. | |
T | Distance (T _x, T _y, T _z, T _w) const |
Calc distance to the given point. | |
T | Dot (const Vector4< T > &_v) const |
Return the dot product of this vector and another vector. | |
bool | Equal (const Vector4 &_v, const T &_tol) const |
Equality test with tolerance. | |
bool | IsFinite () const |
See if a point is finite (e.g., not nan) | |
T | Length () const |
Returns the length (magnitude) of the vector. | |
T | Max () const |
Get the maximum value in the vector. | |
void | Max (const Vector4< T > &_v) |
Set this vector's components to the maximum of itself and the passed in vector. | |
T | Min () const |
Get the minimum value in the vector. | |
void | Min (const Vector4< T > &_v) |
Set this vector's components to the minimum of itself and the passed in vector. | |
void | Normalize () |
Normalize the vector length. | |
Vector4 | Normalized () const |
Return a normalized vector. | |
bool | operator!= (const Vector4< T > &_pt) const |
Not equal to operator. | |
const Vector4< T > | operator* (const Matrix4< T > &_m) const |
Matrix multiplication operator. | |
const Vector4< T > | operator* (const Vector4< T > &_pt) const |
Multiplication operator. | |
const Vector4< T > | operator* (T _v) const |
Multiplication operators. | |
const Vector4< T > & | operator*= (const Vector4< T > &_pt) |
Multiplication assignment operator. | |
const Vector4< T > & | operator*= (T _v) |
Multiplication assignment operator. | |
Vector4< T > | operator+ (const T _s) const |
Addition operators. | |
Vector4< T > | operator+ (const Vector4< T > &_v) const |
Addition operator. | |
const Vector4< T > & | operator+= (const T _s) |
Addition assignment operator. | |
const Vector4< T > & | operator+= (const Vector4< T > &_v) |
Addition operator. | |
Vector4 | operator- () const |
Negation operator. | |
Vector4< T > | operator- (const T _s) const |
Subtraction operators. | |
Vector4< T > | operator- (const Vector4< T > &_v) const |
Subtraction operator. | |
const Vector4< T > & | operator-= (const T _s) |
Subtraction assignment operator. | |
const Vector4< T > & | operator-= (const Vector4< T > &_v) |
Subtraction assigment operators. | |
const Vector4< T > | operator/ (const Vector4< T > &_v) const |
Division assignment operator. | |
const Vector4< T > | operator/ (T _v) const |
Division assignment operator. | |
const Vector4< T > & | operator/= (const Vector4< T > &_v) |
Division assignment operator. | |
const Vector4< T > & | operator/= (T _v) |
Division operator. | |
bool | operator< (const Vector4< T > &_pt) const |
Less than operator. | |
Vector4< T > & | operator= (T _value) |
Assignment operator. | |
bool | operator== (const Vector4< T > &_v) const |
Equal to operator. | |
T & | operator[] (const std::size_t _index) |
Array subscript operator. | |
T | operator[] (const std::size_t _index) const |
Const-qualified array subscript operator. | |
void | Round () |
Round to near whole number. | |
Vector4 | Rounded () const |
Get a rounded version of this vector. | |
void | Set (T _x=0, T _y=0, T _z=0, T _w=0) |
Set the contents of the vector. | |
T | SquaredLength () const |
Return the square of the length (magnitude) of the vector. | |
T | Sum () const |
Return the sum of the values. | |
T & | W () |
Return a mutable w value. | |
T | W () const |
Get the w value. | |
void | W (const T &_v) |
Set the w value. | |
T & | X () |
Return a mutable x value. | |
T | X () const |
Get the x value. | |
void | X (const T &_v) |
Set the x value. | |
T & | Y () |
Return a mutable y value. | |
T | Y () const |
Get the y value. | |
void | Y (const T &_v) |
Set the y value. | |
T & | Z () |
Return a mutable z value. | |
T | Z () const |
Get the z value. | |
void | Z (const T &_v) |
Set the z value. | |
Static Public Attributes | |
static const Vector4 & | NaN = detail::gVector4NaN<T> |
math::Vector4(NaN, NaN, NaN, NaN) | |
static const Vector4< T > & | One = detail::gVector4One<T> |
math::Vector4(1, 1, 1, 1) | |
static const Vector4< T > & | Zero = detail::gVector4Zero<T> |
math::Vector4(0, 0, 0, 0) | |
Detailed Description
class gz::math::Vector4< T >
T Generic x, y, z, w vector.
Constructor & Destructor Documentation
◆ Vector4() [1/2]
Constructor.
Referenced by Vector4< T >::Abs(), Vector4< T >::Distance(), and Vector4< T >::operator-().
◆ Vector4() [2/2]
|
inlineconstexpr |
Constructor with component values.
- Parameters
-
[in] _x value along x axis [in] _y value along y axis [in] _z value along z axis [in] _w value along w axis
Member Function Documentation
◆ Abs()
Get the absolute value of the vector.
- Returns
- a vector with positive elements
References Vector4< T >::Vector4().
◆ AbsDot()
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) + abs(z1 * z2) + abs(w1 * w2)
- Parameters
-
[in] _v the vector
- Returns
- The absolute dot product
◆ Correct()
Corrects any nan values.
References std::isfinite().
◆ Distance() [1/2]
Calc distance to the given point.
- Parameters
-
[in] _pt the point
- Returns
- the distance
Referenced by Vector4< T >::Distance().
◆ Distance() [2/2]
|
inline |
Calc distance to the given point.
- Parameters
-
[in] _x value along x [in] _y value along y [in] _z value along z [in] _w value along w
- Returns
- the distance
References Vector4< T >::Vector4(), and Vector4< T >::Distance().
◆ Dot()
Return the dot product of this vector and another vector.
- Parameters
-
[in] _v the vector
- Returns
- the dot product
◆ Equal()
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 Vector4< T >::operator==().
◆ IsFinite()
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 Vector4< T >::SquaredLength().
Referenced by Vector4< T >::Normalize().
◆ Max() [1/2]
|
inline |
◆ Max() [2/2]
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]
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()
Normalize the vector length.
References Vector4< T >::Length().
◆ Normalized()
Return a normalized vector.
- Returns
- unit length vector
◆ operator!=()
Not equal to operator.
- Parameters
-
[in] _pt the other vector
- Returns
- false if each component is equal within a default tolerence (1e-6), true otherwise
◆ operator*() [1/3]
Matrix multiplication operator.
- Parameters
-
[in] _m matrix
- Returns
- the vector multiplied by _m
◆ operator*() [2/3]
Multiplication operator.
- Remarks
- Performs element wise multiplication, which has limited use.
- Parameters
-
[in] _pt another vector
- Returns
- result vector
◆ operator*() [3/3]
Multiplication operators.
- Parameters
-
[in] _v scaling factor
- Returns
- a scaled vector
◆ operator*=() [1/2]
Multiplication assignment operator.
- Remarks
- Performs element wise multiplication, which has limited use.
- Parameters
-
[in] _pt a vector
- Returns
- this
◆ operator*=() [2/2]
Multiplication assignment operator.
- Parameters
-
[in] _v scaling factor
- Returns
- this
◆ operator+() [1/2]
Addition operators.
- Parameters
-
[in] _s the scalar addend
- Returns
- sum vector
◆ operator+() [2/2]
Addition operator.
- Parameters
-
[in] _v the vector to add
- Returns
- a sum vector
◆ operator+=() [1/2]
Addition assignment operator.
- Parameters
-
[in] _s scalar addend
- Returns
- this
◆ operator+=() [2/2]
Addition operator.
- Parameters
-
[in] _v the vector to add
- Returns
- this vector
◆ operator-() [1/3]
◆ operator-() [2/3]
Subtraction operators.
- Parameters
-
[in] _s the scalar subtrahend
- Returns
- difference vector
◆ operator-() [3/3]
Subtraction operator.
- Parameters
-
[in] _v the vector to substract
- Returns
- a vector
◆ operator-=() [1/2]
Subtraction assignment operator.
- Parameters
-
[in] _s scalar subtrahend
- Returns
- this
◆ operator-=() [2/2]
Subtraction assigment operators.
- Parameters
-
[in] _v the vector to substract
- Returns
- this vector
◆ operator/() [1/2]
Division assignment operator.
- Remarks
- Performs element wise division, which has limited use.
- Parameters
-
[in] _v the vector to perform element wise division with
- Returns
- a result vector
◆ operator/() [2/2]
Division assignment operator.
- Remarks
- Performs element wise division, which has limited use.
- Parameters
-
[in] _v another vector
- Returns
- a result vector
◆ operator/=() [1/2]
Division assignment operator.
- Remarks
- Performs element wise division, which has limited use.
- Parameters
-
[in] _v the vector to perform element wise division with
- Returns
- this
◆ operator/=() [2/2]
Division operator.
- Parameters
-
[in] _v scaling factor
- Returns
- a vector
◆ operator<()
◆ operator=()
Assignment operator.
- Parameters
-
[in] _value
◆ operator==()
Equal to operator.
- Parameters
-
[in] _v the other vector
- Returns
- true if each component is equal within a default tolerence (1e-6), false otherwise
References Vector4< T >::Equal().
◆ operator[]() [1/2]
|
inline |
Array subscript operator.
- Parameters
-
[in] _index The index, where 0 == x, 1 == y, 2 == z, 3 == w. The index is clamped to the range (0,3).
- Returns
- The value.
References gz::math::clamp(), gz::math::GZ_THREE_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, 1 == y, 2 == z, 3 == w. The index is clamped to the range (0,3).
- Returns
- The value.
References gz::math::clamp(), gz::math::GZ_THREE_SIZE_T, and gz::math::GZ_ZERO_SIZE_T.
◆ Round()
Round to near whole number.
References std::nearbyint().
◆ Rounded()
Get a rounded version of this vector.
- Returns
- a rounded vector
◆ Set()
Set the contents of the vector.
- Parameters
-
[in] _x value along x axis [in] _y value along y axis [in] _z value along z axis [in] _w value along w axis
◆ SquaredLength()
|
inline |
Return the square of the length (magnitude) of the vector.
- Returns
- the length
Referenced by Vector4< T >::Length().
◆ Sum()
|
inline |
Return the sum of the values.
- Returns
- the sum
◆ W() [1/3]
|
inline |
Return a mutable w value.
- Returns
- The w component of the vector
◆ W() [2/3]
|
inline |
Get the w value.
- Returns
- The w component of the vector
◆ W() [3/3]
Set the w value.
- Parameters
-
[in] _v Value for the w component.
◆ X() [1/3]
|
inline |
Return a mutable x value.
- Returns
- The x component of the vector
◆ X() [2/3]
|
inline |
Get the x value.
- Returns
- The x component of the vector
◆ X() [3/3]
Set the x value.
- Parameters
-
[in] _v Value for the x component.
◆ Y() [1/3]
|
inline |
Return a mutable y value.
- Returns
- The y component of the vector
◆ Y() [2/3]
|
inline |
Get the y value.
- Returns
- The y component of the vector
◆ Y() [3/3]
Set the y value.
- Parameters
-
[in] _v Value for the y component.
◆ Z() [1/3]
|
inline |
Return a mutable z value.
- Returns
- The z component of the vector
◆ Z() [2/3]
|
inline |
Get the z value.
- Returns
- The z component of the vector
◆ Z() [3/3]
Set the z value.
- Parameters
-
[in] _v Value for the z component.
Member Data Documentation
◆ NaN
math::Vector4(NaN, NaN, NaN, NaN)
◆ One
math::Vector4(1, 1, 1, 1)
◆ Zero
math::Vector4(0, 0, 0, 0)
The documentation for this class was generated from the following file: