Loading...
Searching...
No Matches
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T > Class Template Reference

Two dimensional (x, y) vector. More...

#include <ignition/math/Vector2.hh>

Public Member Functions

 Vector2 ()
 Default Constructor.
 
 Vector2 (const T &_x, const T &_y)
 Constructor.
 
 Vector2 (const Vector2< T > &_v)
 Copy constructor.
 
virtual ~Vector2 ()
 Destructor.
 
double Distance (const Vector2 &_pt) const
 Calc distance to the given point.
 
Dot (const Vector2< T > &_v) const
 Get the dot product of this vector and _v.
 
bool Equal (const Vector2 &_v, const T &_tol) const
 Equality test with tolerance.
 
bool IsFinite () const
 See if a point is finite (e.g., not nan)
 
Length () const
 Returns the length (magnitude) of the vector.
 
void Normalize ()
 Normalize the vector length.
 
bool operator!= (const Vector2 &_v) const
 Not equal to operator.
 
const Vector2 operator* (const Vector2 &_v) const
 Multiplication operators.
 
const Vector2 operator* (T _v) const
 Multiplication operators.
 
const Vector2operator*= (const Vector2 &_v)
 Multiplication assignment operator.
 
const Vector2operator*= (T _v)
 Multiplication assignment operator.
 
Vector2< T > operator+ (const T _s) const
 Addition operators.
 
Vector2 operator+ (const Vector2 &_v) const
 Addition operator.
 
const Vector2< T > & operator+= (const T _s)
 Addition assignment operator.
 
const Vector2operator+= (const Vector2 &_v)
 Addition assignment operator.
 
Vector2 operator- () const
 Negation operator.
 
Vector2< T > operator- (const T _s) const
 Subtraction operators.
 
Vector2 operator- (const Vector2 &_v) const
 Subtraction operator.
 
const Vector2operator-= (const Vector2 &_v)
 Subtraction assignment operator.
 
const Vector2< T > & operator-= (T _s)
 Subtraction assignment operator.
 
const Vector2 operator/ (const Vector2 &_v) const
 Division operator.
 
const Vector2 operator/ (T _v) const
 Division operator.
 
const Vector2operator/= (const Vector2 &_v)
 Division operator.
 
const Vector2operator/= (T _v)
 Division operator.
 
bool operator< (const Vector2< T > &_pt) const
 Less than operator.
 
Vector2operator= (const Vector2 &_v)
 Assignment operator.
 
const Vector2operator= (T _v)
 Assignment operator.
 
bool operator== (const Vector2 &_v) const
 Equal to operator.
 
T & operator[] (const std::size_t _index)
 Array subscript operator.
 
operator[] (const std::size_t _index) const
 Const-qualified array subscript operator.
 
void Set (T _x, T _y)
 Set the contents of the vector.
 
SquaredLength () const
 Returns the square of the length (magnitude) of the vector.
 
T & X ()
 Return a mutable x value.
 
X () const
 Return the x value.
 
void X (const T &_v)
 Set the x value.
 
T & Y ()
 Return a mutable y value.
 
Y () const
 Return the y value.
 
void Y (const T &_v)
 Set the y value.
 

Static Public Attributes

static const Vector2< T > One
 math::Vector2(1, 1)
 
static const Vector2< T > Zero
 math::Vector2(0, 0)
 

Detailed Description

template<typename T>
class ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >

Two dimensional (x, y) vector.

Constructor & Destructor Documentation

◆ Vector2() [1/3]

◆ Vector2() [2/3]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2 ( const T & _x,
const T & _y )
inline

Constructor.

Parameters
[in]_xvalue along x
[in]_yvalue along y

◆ Vector2() [3/3]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2 ( const Vector2< T > & _v)
inline

Copy constructor.

Parameters
[in]_vthe value

◆ ~Vector2()

template<typename T >
virtual ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::~Vector2 ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ Distance()

template<typename T >
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Distance ( const Vector2< T > & _pt) const
inline

Calc distance to the given point.

Parameters
[in]_ptThe point to measure to
Returns
the distance

◆ Dot()

template<typename T >
T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Dot ( const Vector2< T > & _v) const
inline

Get the dot product of this vector and _v.

Parameters
[in]_vthe vector
Returns
The dot product

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Contains().

◆ Equal()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Equal ( const Vector2< T > & _v,
const T & _tol ) const
inline

Equality test with tolerance.

Parameters
[in]_vthe vector to compare to
[in]_tolequality tolerance.
Returns
true if the elements of the vectors are equal within the tolerence specified by _tol.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::equal().

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator==().

◆ IsFinite()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::IsFinite ( ) const
inline

See if a point is finite (e.g., not nan)

Returns
true if finite, false otherwise

◆ Length()

template<typename T >
T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Length ( ) const
inline

◆ Normalize()

◆ operator!=()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator!= ( const Vector2< T > & _v) const
inline

Not equal to operator.

Returns
true if elements are of diffent values (tolerence 1e-6)

◆ operator*() [1/2]

template<typename T >
const Vector2 ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator* ( const Vector2< T > & _v) const
inline

Multiplication operators.

Parameters
[in]_vthe vector
Returns
the result

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator*() [2/2]

template<typename T >
const Vector2 ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator* ( T _v) const
inline

Multiplication operators.

Parameters
[in]_vthe scaling factor
Returns
a scaled vector

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator*=() [1/2]

template<typename T >
const Vector2 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator*= ( const Vector2< T > & _v)
inline

Multiplication assignment operator.

Remarks
this is an element wise multiplication
Parameters
[in]_vthe vector
Returns
this

◆ operator*=() [2/2]

template<typename T >
const Vector2 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator*= ( T _v)
inline

Multiplication assignment operator.

Parameters
[in]_vthe scaling factor
Returns
a scaled vector

◆ operator+() [1/2]

template<typename T >
Vector2< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator+ ( const T _s) const
inline

Addition operators.

Parameters
[in]_sthe scalar addend
Returns
sum vector

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator+() [2/2]

template<typename T >
Vector2 ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator+ ( const Vector2< T > & _v) const
inline

Addition operator.

Parameters
[in]_vvector to add
Returns
sum vector

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator+=() [1/2]

template<typename T >
const Vector2< T > & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator+= ( const T _s)
inline

Addition assignment operator.

Parameters
[in]_sscalar addend
Returns
this

◆ operator+=() [2/2]

template<typename T >
const Vector2 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator+= ( const Vector2< T > & _v)
inline

Addition assignment operator.

Parameters
[in]_vthe vector to add

◆ operator-() [1/3]

template<typename T >
Vector2 ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator- ( ) const
inline

Negation operator.

Returns
negative of this vector

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator-() [2/3]

template<typename T >
Vector2< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator- ( const T _s) const
inline

Subtraction operators.

Parameters
[in]_sthe scalar subtrahend
Returns
difference vector

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator-() [3/3]

template<typename T >
Vector2 ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator- ( const Vector2< T > & _v) const
inline

Subtraction operator.

Parameters
[in]_vthe vector to substract
Returns
the subtracted vector

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator-=() [1/2]

template<typename T >
const Vector2 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator-= ( const Vector2< T > & _v)
inline

Subtraction assignment operator.

Parameters
[in]_vthe vector to substract
Returns
this

◆ operator-=() [2/2]

template<typename T >
const Vector2< T > & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator-= ( T _s)
inline

Subtraction assignment operator.

Parameters
[in]_sscalar subtrahend
Returns
this

◆ operator/() [1/2]

template<typename T >
const Vector2 ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator/ ( const Vector2< T > & _v) const
inline

Division operator.

Remarks
this is an element wise division
Parameters
[in]_va vector
Returns
a result

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator/() [2/2]

template<typename T >
const Vector2 ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator/ ( T _v) const
inline

Division operator.

Parameters
[in]_vthe value
Returns
a vector

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Vector2().

◆ operator/=() [1/2]

template<typename T >
const Vector2 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator/= ( const Vector2< T > & _v)
inline

Division operator.

Remarks
this is an element wise division
Parameters
[in]_va vector
Returns
this

◆ operator/=() [2/2]

template<typename T >
const Vector2 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator/= ( T _v)
inline

Division operator.

Parameters
[in]_vthe divisor
Returns
a vector

◆ operator<()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator< ( const Vector2< T > & _pt) const
inline

Less than operator.

Parameters
[in]_ptVector 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]

template<typename T >
Vector2 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator= ( const Vector2< T > & _v)
inline

Assignment operator.

Parameters
[in]_va value for x and y element
Returns
this

◆ operator=() [2/2]

template<typename T >
const Vector2 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator= ( T _v)
inline

Assignment operator.

Parameters
[in]_vthe value for x and y element
Returns
this

◆ operator==()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator== ( const Vector2< T > & _v) const
inline

Equal to operator.

Parameters
[in]_vthe vector to compare to
Returns
true if the elements of the 2 vectors are equal within a tolerence (1e-6)

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Equal().

◆ operator[]() [1/2]

template<typename T >
T & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator[] ( const std::size_t _index)
inline

Array subscript operator.

Parameters
[in]_indexThe index, where 0 == x and 1 == y. The index is clamped to the range [0,1].

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ONE_SIZE_T, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ZERO_SIZE_T.

◆ operator[]() [2/2]

template<typename T >
T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::operator[] ( const std::size_t _index) const
inline

Const-qualified array subscript operator.

Parameters
[in]_indexThe index, where 0 == x and 1 == y. The index is clamped to the range [0,1].

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ONE_SIZE_T, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ZERO_SIZE_T.

◆ Set()

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Set ( T _x,
T _y )
inline

Set the contents of the vector.

Parameters
[in]_xvalue along x
[in]_yvalue along y

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MassMatrix3< T >::PrincipalAxesOffset().

◆ SquaredLength()

template<typename T >
T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::SquaredLength ( ) const
inline

Returns the square of the length (magnitude) of the vector.

Returns
The squared length

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Length(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MassMatrix3< T >::PrincipalAxesOffset().

◆ X() [1/3]

template<typename T >
T & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::X ( )
inline

Return a mutable x value.

Returns
Value of the X component.

◆ X() [2/3]

◆ X() [3/3]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::X ( const T & _v)
inline

Set the x value.

Parameters
[in]_vValue for the x component.

◆ Y() [1/3]

template<typename T >
T & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Y ( )
inline

Return a mutable y value.

Returns
Value of the Y component.

◆ Y() [2/3]

◆ Y() [3/3]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Y ( const T & _v)
inline

Set the y value.

Parameters
[in]_vValue for the y component.

Member Data Documentation

◆ One

template<typename T >
const Vector2< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::One
static

math::Vector2(1, 1)

◆ Zero

template<typename T >
const Vector2< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Zero
static

math::Vector2(0, 0)


The documentation for this class was generated from the following file: