The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to keep coordinate system related information, its elements are labeled by x, y, z. More...
#include <gz/math/Vector3.hh>
Public Member Functions | |
constexpr | Vector3 () |
Constructor. More... | |
constexpr | Vector3 (const T &_x, const T &_y, const T &_z) |
Constructor. More... | |
Vector3 (const Vector3< T > &_v)=default | |
Copy constructor. More... | |
~Vector3 ()=default | |
Destructor. More... | |
Vector3 | Abs () const |
Get the absolute value of the vector. More... | |
T | AbsDot (const Vector3< 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... | |
Vector3 | Cross (const Vector3< T > &_v) const |
Return the cross product of this vector with another vector. More... | |
T | Distance (const Vector3< T > &_pt) const |
Calc distance to the given point. More... | |
T | Distance (T _x, T _y, T _z) const |
Calc distance to the given point. More... | |
T | DistToLine (const Vector3< T > &_pt1, const Vector3 &_pt2) |
Get distance to an infinite line defined by 2 points. More... | |
T | Dot (const Vector3< T > &_v) const |
Return the dot product of this vector and another vector. More... | |
bool | Equal (const Vector3 &_v, const T &_tol) const |
Equality test with tolerance. More... | |
bool | Equal (const Vector3< T > &_v) const |
Equality test. 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 Vector3< T > &_v) |
Set this vector's components to the maximum of itself and the passed in vector. More... | |
T | MaxAbs () const |
Get the number with the maximum absolute value in the vector. More... | |
T | Min () const |
Get the minimum value in the vector. More... | |
void | Min (const Vector3< T > &_v) |
Set this vector's components to the minimum of itself and the passed in vector. More... | |
T | MinAbs () const |
Get the number with the maximum absolute value in the vector. More... | |
Vector3 | Normalize () |
Normalize the vector length. More... | |
Vector3 | Normalized () const |
Return a normalized vector. More... | |
bool | operator!= (const Vector3< T > &_v) const |
Not equal to operator. More... | |
Vector3< T > | operator* (const Vector3< T > &_p) const |
Multiplication operator. More... | |
Vector3< T > | operator* (T _s) const |
Multiplication operators. More... | |
const Vector3< T > & | operator*= (const Vector3< T > &_v) |
Multiplication assignment operators. More... | |
const Vector3< T > & | operator*= (T _v) |
Multiplication operator. More... | |
Vector3< T > | operator+ (const T _s) const |
Addition operators. More... | |
Vector3 | operator+ (const Vector3< T > &_v) const |
Addition operator. More... | |
const Vector3< T > & | operator+= (const T _s) |
Addition assignment operator. More... | |
const Vector3 & | operator+= (const Vector3< T > &_v) |
Addition assignment operator. More... | |
Vector3 | operator- () const |
Negation operator. More... | |
Vector3< T > | operator- (const T _s) const |
Subtraction operators. More... | |
Vector3< T > | operator- (const Vector3< T > &_pt) const |
Subtraction operators. More... | |
const Vector3< T > & | operator-= (const T _s) |
Subtraction assignment operator. More... | |
const Vector3< T > & | operator-= (const Vector3< T > &_pt) |
Subtraction assignment operators. More... | |
const Vector3< T > | operator/ (const Vector3< T > &_pt) const |
Division operator. More... | |
const Vector3< T > | operator/ (T _v) const |
Division operator. More... | |
const Vector3< T > & | operator/= (const Vector3< T > &_pt) |
Division assignment operator. More... | |
const Vector3< T > & | operator/= (T _v) |
Division assignment operator. More... | |
bool | operator< (const Vector3< T > &_pt) const |
Less than operator. More... | |
Vector3 & | operator= (const Vector3< T > &_v)=default |
Assignment operator. More... | |
Vector3 & | operator= (T _v) |
Assignment operator. More... | |
bool | operator== (const Vector3< T > &_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... | |
Vector3 | Perpendicular () const |
Return a vector that is perpendicular to this one. More... | |
Vector3 | Round () |
Round to near whole number, return the result. More... | |
void | Round (int _precision) |
Round all values to _precision decimal places. More... | |
Vector3 | Rounded () const |
Get a rounded version of this vector. More... | |
void | Set (T _x=0, T _y=0, T _z=0) |
Set the contents of the vector. More... | |
T | SquaredLength () const |
Return the square of the length (magnitude) of the vector. More... | |
T | Sum () const |
Return the sum of the values. More... | |
T & | X () |
Get a mutable reference to the x value. More... | |
T | X () const |
Get the x value. More... | |
void | X (const T &_v) |
Set the x value. More... | |
T & | Y () |
Get a mutable reference to the y value. More... | |
T | Y () const |
Get the y value. More... | |
void | Y (const T &_v) |
Set the y value. More... | |
T & | Z () |
Get a mutable reference to the z value. More... | |
T | Z () const |
Get the z value. More... | |
void | Z (const T &_v) |
Set the z value. More... | |
Static Public Member Functions | |
static Vector3 | Normal (const Vector3< T > &_v1, const Vector3< T > &_v2, const Vector3< T > &_v3) |
Get a normal vector to a triangle. More... | |
Static Public Attributes | |
static const Vector3 & | NaN = detail::gVector3NaN<T> |
math::Vector3(NaN, NaN, NaN) More... | |
static const Vector3 & | One = detail::gVector3One<T> |
math::Vector3(1, 1, 1) More... | |
static const Vector3 & | UnitX = detail::gVector3UnitX<T> |
math::Vector3(1, 0, 0) More... | |
static const Vector3 & | UnitY = detail::gVector3UnitY<T> |
math::Vector3(0, 1, 0) More... | |
static const Vector3 & | UnitZ = detail::gVector3UnitZ<T> |
math::Vector3(0, 0, 1) More... | |
static const Vector3 & | Zero = detail::gVector3Zero<T> |
math::Vector3(0, 0, 0) More... | |
Detailed Description
template<typename T>
class gz::math::Vector3< T >
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to keep coordinate system related information, its elements are labeled by x, y, z.
Constructor & Destructor Documentation
◆ Vector3() [1/3]
|
inlineconstexpr |
◆ Vector3() [2/3]
|
inlineconstexpr |
Constructor.
- Parameters
-
[in] _x value along x [in] _y value along y [in] _z value along z
◆ Vector3() [3/3]
◆ ~Vector3()
|
default |
Destructor.
Member Function Documentation
◆ Abs()
|
inline |
Get the absolute value of the vector.
- Returns
- a vector with positive elements
References Vector3< T >::Vector3().
Referenced by Quaternion< T >::SetFrom2Axes(), and OrientedBox< T >::Size().
◆ 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) + abs(z1 *z2)
- Parameters
-
[in] _v the vector
- Returns
- The absolute dot product
◆ Correct()
|
inline |
Corrects any nan values.
References std::isfinite().
◆ Cross()
Return the cross product of this vector with another vector.
- Parameters
-
[in] _v a vector
- Returns
- the cross product
References Vector3< T >::Vector3().
Referenced by Vector3< T >::DistToLine(), Plane< T >::Intersection(), Vector3< T >::Normal(), Quaternion< T >::operator*(), Vector3< T >::Perpendicular(), Matrix3< T >::SetFrom2Axes(), and Quaternion< T >::SetFrom2Axes().
◆ Distance() [1/2]
|
inline |
Calc distance to the given point.
- Parameters
-
[in] _pt the point
- Returns
- the distance
Referenced by Vector3< 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
- Returns
- the distance
References Vector3< T >::Vector3(), and Vector3< T >::Distance().
◆ DistToLine()
Get distance to an infinite line defined by 2 points.
- Parameters
-
[in] _pt1 first point on the line [in] _pt2 second point on the line
- Returns
- the minimum distance from this point to the line
References Vector3< T >::Cross(), and Vector3< T >::Length().
◆ Dot()
|
inline |
Return the dot product of this vector and another vector.
- Parameters
-
[in] _v the vector
- Returns
- the dot product
Referenced by Triangle3< T >::Contains(), Line3< T >::Distance(), Plane< T >::Distance(), Plane< T >::Intersection(), Triangle3< T >::Intersects(), Matrix3< T >::SetFrom2Axes(), and Quaternion< T >::SetFrom2Axes().
◆ Equal() [1/2]
|
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 Vector3< T >::operator==(), and MassMatrix3< T >::PrincipalAxesOffset().
◆ Equal() [2/2]
|
inline |
Equality test.
- Remarks
- This is equivalent to the == operator
- Parameters
-
[in] _v the other vector
- Returns
- true if the 2 vectors have the same values, false otherwise
◆ IsFinite()
|
inline |
See if a point is finite (e.g., not nan)
- Returns
- true if is finite or false otherwise
References std::isfinite().
◆ Length()
|
inline |
Returns the length (magnitude) of the vector.
- Returns
- the length
References Vector3< T >::SquaredLength().
Referenced by Line3< T >::Distance(), Vector3< T >::DistToLine(), and Vector3< 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
◆ MaxAbs()
|
inline |
Get the number with the maximum absolute value in the vector.
- Returns
- the element with maximum absolute value
References gz::math::max(), and 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
Referenced by MassMatrix3< T >::SetFromBox().
◆ MinAbs()
|
inline |
Get the number with the maximum absolute value in the vector.
- Returns
- the element with minimum absolute value
References gz::math::min(), and std::min().
◆ Normal()
|
inlinestatic |
Get a normal vector to a triangle.
- Parameters
-
[in] _v1 first vertex of the triangle [in] _v2 second vertex [in] _v3 third vertex
- Returns
- the normal
References Vector3< T >::Cross(), and Vector3< T >::Normalize().
Referenced by Triangle3< T >::Normal().
◆ Normalize()
|
inline |
Normalize the vector length.
- Returns
- unit length vector
References Vector3< T >::Length().
Referenced by Matrix4< T >::LookAt(), Vector3< T >::Normal(), Vector3< T >::Normalized(), Matrix3< T >::SetFrom2Axes(), and Quaternion< T >::SetFrom2Axes().
◆ Normalized()
|
inline |
◆ operator!=()
|
inline |
Not equal to operator.
- Parameters
-
[in] _v The vector to compare against
- Returns
- false if each component is equal within a default tolerence (1e-3), true otherwise
◆ operator*() [1/2]
Multiplication operator.
- Remarks
- this is an element wise multiplication, not a cross product
- Parameters
-
[in] _p multiplier operator
- Returns
- a vector
References Vector3< T >::Vector3().
◆ operator*() [2/2]
|
inline |
Multiplication operators.
- Parameters
-
[in] _s the scaling factor
- Returns
- a scaled vector
◆ operator*=() [1/2]
Multiplication assignment operators.
- Remarks
- this is an element wise multiplication, not a cross product
- Parameters
-
[in] _v a vector
- Returns
- this
◆ operator*=() [2/2]
|
inline |
Multiplication operator.
- Parameters
-
[in] _v scaling factor
- Returns
- this
◆ 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
- the sum vector
References Vector3< T >::Vector3().
◆ operator+=() [1/2]
|
inline |
Addition assignment operator.
- Parameters
-
[in] _s scalar addend
- Returns
- this
◆ operator+=() [2/2]
Addition assignment operator.
- Parameters
-
[in] _v vector to add
- Returns
- the sum vector
◆ operator-() [1/3]
|
inline |
◆ operator-() [2/3]
|
inline |
Subtraction operators.
- Parameters
-
[in] _s the scalar subtrahend
- Returns
- difference vector
◆ operator-() [3/3]
Subtraction operators.
- Parameters
-
[in] _pt a vector to substract
- Returns
- a vector after the substraction
References Vector3< T >::Vector3().
◆ operator-=() [1/2]
|
inline |
Subtraction assignment operator.
- Parameters
-
[in] _s scalar subtrahend
- Returns
- this
◆ operator-=() [2/2]
Subtraction assignment operators.
- Parameters
-
[in] _pt subtrahend
- Returns
- a vector after the substraction
◆ operator/() [1/2]
Division operator.
- Remarks
- this is an element wise division
- Parameters
-
[in] _pt the vector divisor
- Returns
- a vector
References Vector3< T >::Vector3().
◆ operator/() [2/2]
|
inline |
Division operator.
- Remarks
- this is an element wise division
- Parameters
-
[in] _v the divisor
- Returns
- a vector
References Vector3< T >::Vector3().
◆ operator/=() [1/2]
Division assignment operator.
- Remarks
- this is an element wise division
- Parameters
-
[in] _pt the vector divisor
- Returns
- a vector
◆ operator/=() [2/2]
|
inline |
Division assignment operator.
- Remarks
- this is an element wise division
- Parameters
-
[in] _v the divisor
- Returns
- this
◆ operator<()
|
inline |
◆ operator=() [1/2]
Assignment operator.
- Parameters
-
[in] _v a new value
- Returns
- this
◆ operator=() [2/2]
|
inline |
Assignment operator.
- Parameters
-
[in] _v assigned to all elements
- Returns
- this
◆ operator==()
|
inline |
Equal to operator.
- Parameters
-
[in] _v The vector to compare against
- Returns
- true if each component is equal within a default tolerence (1e-3), false otherwise
References Vector3< T >::Equal().
◆ operator[]() [1/2]
|
inline |
Array subscript operator.
- Parameters
-
[in] _index The index, where 0 == x, 1 == y, 2 == z. The index is clamped to the range [0,2].
- Returns
- The value.
References gz::math::clamp(), gz::math::GZ_TWO_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. The index is clamped to the range [0,2].
- Returns
- The value.
References gz::math::clamp(), gz::math::GZ_TWO_SIZE_T, and gz::math::GZ_ZERO_SIZE_T.
◆ Perpendicular()
|
inline |
Return a vector that is perpendicular to this one.
- Returns
- an orthogonal vector
References Vector3< T >::Vector3(), Vector3< T >::Cross(), and Vector3< T >::SquaredLength().
◆ Round() [1/2]
|
inline |
Round to near whole number, return the result.
- Returns
- the result
References std::nearbyint().
Referenced by Vector3< T >::Rounded().
◆ Round() [2/2]
|
inline |
Round all values to _precision decimal places.
- Parameters
-
[in] _precision the decimal places
References gz::math::precision().
◆ Rounded()
|
inline |
◆ Set()
|
inline |
Set the contents of the vector.
- Parameters
-
[in] _x value along x [in] _y value along y [in] _z value aling z
Referenced by Quaternion< T >::AxisAngle(), Quaternion< T >::SetFrom2Axes(), and Matrix4< T >::TransformAffine().
◆ SquaredLength()
|
inline |
Return the square of the length (magnitude) of the vector.
- Returns
- the squared length
Referenced by Quaternion< T >::Integrate(), Vector3< T >::Length(), Vector3< T >::Perpendicular(), Matrix3< T >::SetFrom2Axes(), and Quaternion< T >::SetFrom2Axes().
◆ Sum()
|
inline |
Return the sum of the values.
- Returns
- the sum
Referenced by MassMatrix3< T >::Epsilon(), and MassMatrix3< T >::PrincipalMoments().
◆ X() [1/3]
|
inline |
Get a mutable reference to the x value.
- Returns
- The x component of the vector
◆ X() [2/3]
|
inline |
Get the x value.
- Returns
- The x component of the vector
Referenced by Matrix4< T >::Axis(), Region3< T >::Contains(), OrientedBox< T >::Contains(), Pose3< T >::CoordPositionAdd(), Line3< T >::Distance(), MassMatrix3< T >::EquivalentBox(), Quaternion< T >::Euler(), Matrix4< T >::EulerRotation(), AdditivelySeparableScalarField3< ScalarFunctionT, ScalarT >::Evaluate(), VolumetricGridLookupField< T, I >::GetInterpolators(), Quaternion< T >::Integrate(), Matrix4< T >::LookAt(), AdditivelySeparableScalarField3< ScalarFunctionT, ScalarT >::Minimum(), Matrix3< T >::operator*(), Matrix4< T >::operator*(), Inertial< T >::operator+=(), Inertial< T >::operator-=(), Quaternion< T >::RotateVector(), Quaternion< T >::RotateVectorReverse(), Matrix4< T >::Scale(), Quaternion< T >::Scale(), Matrix3< T >::SetCol(), Quaternion< T >::SetFrom2Axes(), Quaternion< T >::SetFromAxisAngle(), Matrix3< T >::SetFromAxisAngle(), MassMatrix3< T >::SetFromBox(), Quaternion< T >::SetFromEuler(), Matrix4< T >::SetTranslation(), Matrix4< T >::TransformAffine(), and Line3< T >::Within().
◆ X() [3/3]
|
inline |
Set the x value.
- Parameters
-
[in] _v Value for the x component.
◆ Y() [1/3]
|
inline |
Get a mutable reference to the y value.
- Returns
- The y component of the vector
◆ Y() [2/3]
|
inline |
Get the y value.
- Returns
- The y component of the vector
Referenced by Matrix4< T >::Axis(), Region3< T >::Contains(), Pose3< T >::CoordPositionAdd(), Line3< T >::Distance(), MassMatrix3< T >::EquivalentBox(), Quaternion< T >::Euler(), Matrix4< T >::EulerRotation(), AdditivelySeparableScalarField3< ScalarFunctionT, ScalarT >::Evaluate(), VolumetricGridLookupField< T, I >::GetInterpolators(), Quaternion< T >::Integrate(), Matrix4< T >::LookAt(), AdditivelySeparableScalarField3< ScalarFunctionT, ScalarT >::Minimum(), Matrix3< T >::operator*(), Matrix4< T >::operator*(), Inertial< T >::operator+=(), Inertial< T >::operator-=(), Quaternion< T >::RotateVector(), Quaternion< T >::RotateVectorReverse(), Matrix4< T >::Scale(), Quaternion< T >::Scale(), Matrix3< T >::SetCol(), Quaternion< T >::SetFrom2Axes(), Quaternion< T >::SetFromAxisAngle(), Matrix3< T >::SetFromAxisAngle(), MassMatrix3< T >::SetFromBox(), Quaternion< T >::SetFromEuler(), Matrix4< T >::SetTranslation(), Matrix4< T >::TransformAffine(), and Line3< T >::Within().
◆ Y() [3/3]
|
inline |
Set the y value.
- Parameters
-
[in] _v Value for the y component.
◆ Z() [1/3]
|
inline |
Get a mutable reference to the z value.
- Returns
- The z component of the vector
◆ Z() [2/3]
|
inline |
Get the z value.
- Returns
- The z component of the vector
Referenced by Matrix4< T >::Axis(), Region3< T >::Contains(), Pose3< T >::CoordPositionAdd(), Line3< T >::Distance(), MassMatrix3< T >::EquivalentBox(), Quaternion< T >::Euler(), Matrix4< T >::EulerRotation(), AdditivelySeparableScalarField3< ScalarFunctionT, ScalarT >::Evaluate(), VolumetricGridLookupField< T, I >::GetInterpolators(), Quaternion< T >::Integrate(), Matrix4< T >::LookAt(), AdditivelySeparableScalarField3< ScalarFunctionT, ScalarT >::Minimum(), Matrix3< T >::operator*(), Matrix4< T >::operator*(), Inertial< T >::operator+=(), Inertial< T >::operator-=(), Quaternion< T >::RotateVector(), Quaternion< T >::RotateVectorReverse(), Matrix4< T >::Scale(), Quaternion< T >::Scale(), Matrix3< T >::SetCol(), Quaternion< T >::SetFrom2Axes(), Quaternion< T >::SetFromAxisAngle(), Matrix3< T >::SetFromAxisAngle(), MassMatrix3< T >::SetFromBox(), Quaternion< T >::SetFromEuler(), Matrix4< T >::SetTranslation(), Matrix4< T >::TransformAffine(), and Line3< T >::Within().
◆ Z() [3/3]
|
inline |
Set the z value.
- Parameters
-
[in] _v Value for the z component.
Member Data Documentation
◆ NaN
|
static |
math::Vector3(NaN, NaN, NaN)
◆ One
|
static |
math::Vector3(1, 1, 1)
◆ UnitX
|
static |
math::Vector3(1, 0, 0)
◆ UnitY
|
static |
math::Vector3(0, 1, 0)
◆ UnitZ
|
static |
math::Vector3(0, 0, 1)
◆ Zero
|
static |
math::Vector3(0, 0, 0)
The documentation for this class was generated from the following file: