All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Public Member Functions | Friends | List of all members
ignition::math::Vector2< T > Class Template Reference

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

#include <ignition/math/Vector2.hh>

Public Member Functions

 Vector2 ()
 Default Constructor. More...
 
 Vector2 (const T &_x, const T &_y)
 Constructor. More...
 
 Vector2 (const Vector2< T > &_v)
 Copy constructor. More...
 
virtual ~Vector2 ()
 Destructor. More...
 
double Distance (const Vector2 &_pt) const
 Calc distance to the given point. More...
 
Dot (const Vector2< T > &_v) const
 Get the dot product of this vector and _v. More...
 
bool IsFinite () const
 See if a point is finite (e.g., not nan) More...
 
void Normalize ()
 Normalize the vector length. 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 Vector2operator*= (const Vector2 &_v)
 Multiplication assignment operator. More...
 
const Vector2operator*= (T _v)
 Multiplication assignment operator. More...
 
Vector2 operator+ (const Vector2 &_v) const
 Addition operator. More...
 
const Vector2operator+= (const Vector2 &_v)
 Addition assignment operator. More...
 
Vector2 operator- (const Vector2 &_v) const
 Subtraction operator. More...
 
const Vector2operator-= (const Vector2 &_v)
 Subtraction assignment operator. More...
 
const Vector2 operator/ (const Vector2 &_v) const
 Division operator. More...
 
const Vector2 operator/ (T _v) const
 Division operator. More...
 
const Vector2operator/= (const Vector2 &_v)
 Division operator. More...
 
const Vector2operator/= (T _v)
 Division operator. More...
 
bool operator< (const Vector2< T > &_pt) const
 Less than operator. More...
 
Vector2operator= (const Vector2 &_v)
 Assignment operator. More...
 
const Vector2operator= (T _v)
 Assignment operator. More...
 
bool operator== (const Vector2 &_v) const
 Equal to operator. More...
 
operator[] (size_t _index) const
 Array subscript operator. More...
 
void Set (T _x, T _y)
 Set the contents of the vector. More...
 
X () const
 Return the x value. More...
 
T & X ()
 Return a mutable x value. More...
 
void X (const T &_v)
 Set the x value. More...
 
Y () const
 Return the y value. More...
 
T & Y ()
 Return a mutable y value. More...
 
void Y (const T &_v)
 Set the y value. More...
 

Friends

std::ostream & operator<< (std::ostream &_out, const Vector2< T > &_pt)
 Stream extraction operator. More...
 
std::istream & operator>> (std::istream &_in, Vector2< T > &_pt)
 Stream extraction operator. More...
 

Detailed Description

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

Two dimensional (x, y) vector.

Constructor & Destructor Documentation

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

Constructor.

Parameters
[in]_xvalue along x
[in]_yvalue along y
template<typename T>
ignition::math::Vector2< T >::Vector2 ( const Vector2< T > &  _v)
inline

Copy constructor.

Parameters
[in]_vthe value
template<typename T>
virtual ignition::math::Vector2< T >::~Vector2 ( )
inlinevirtual

Destructor.

Member Function Documentation

template<typename T>
double ignition::math::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
template<typename T>
T ignition::math::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::Triangle< T >::Contains().

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

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

Returns
true if finite, false otherwise
template<typename T>
void ignition::math::Vector2< T >::Normalize ( )
inline

Normalize the vector length.

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

Not equal to operator.

Returns
true if elements are of diffent values (tolerence 1e-6)
template<typename T>
const Vector2 ignition::math::Vector2< T >::operator* ( const Vector2< T > &  _v) const
inline

Multiplication operators.

Parameters
[in]_vthe vector
Returns
the result

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

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

Multiplication operators.

Parameters
[in]_vthe scaling factor
Returns
a scaled vector

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

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

Multiplication assignment operator.

Remarks
this is an element wise multiplication
Parameters
[in]_vthe vector
Returns
this
template<typename T>
const Vector2& ignition::math::Vector2< T >::operator*= ( _v)
inline

Multiplication assignment operator.

Parameters
[in]_vthe scaling factor
Returns
a scaled vector
template<typename T>
Vector2 ignition::math::Vector2< T >::operator+ ( const Vector2< T > &  _v) const
inline

Addition operator.

Parameters
[in]_vvector to add
Returns
sum vector

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

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

Addition assignment operator.

Parameters
[in]_vthe vector to add
template<typename T>
Vector2 ignition::math::Vector2< T >::operator- ( const Vector2< T > &  _v) const
inline

Subtraction operator.

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

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

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

Subtraction assignment operator.

Parameters
[in]_vthe vector to substract
Returns
this
template<typename T>
const Vector2 ignition::math::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::Vector2< T >::Vector2().

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

Division operator.

Parameters
[in]_vthe value
Returns
a vector

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

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

Division operator.

Remarks
this is an element wise division
Parameters
[in]_va vector
Returns
this
template<typename T>
const Vector2& ignition::math::Vector2< T >::operator/= ( _v)
inline

Division operator.

Parameters
[in]_vthe divisor
Returns
a vector
template<typename T>
bool ignition::math::Vector2< T >::operator< ( const Vector2< T > &  _pt) const
inline

Less than operator.

Parameters
[in]_ptVector to compare.
Returns
True if this vector2 first or second value is less than the given vector's first or second value.
template<typename T>
Vector2& ignition::math::Vector2< T >::operator= ( const Vector2< T > &  _v)
inline

Assignment operator.

Parameters
[in]_va value for x and y element
Returns
this
template<typename T>
const Vector2& ignition::math::Vector2< T >::operator= ( _v)
inline

Assignment operator.

Parameters
[in]_vthe value for x and y element
Returns
this
template<typename T>
bool ignition::math::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::equal().

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

Array subscript operator.

Parameters
[in]_indexthe index
Returns
the value. Throws an IndexException if _index is out of bounds.
Exceptions
IndexExceptionif _index is >= 2.
template<typename T>
void ignition::math::Vector2< T >::Set ( _x,
_y 
)
inline

Set the contents of the vector.

Parameters
[in]_xvalue along x
[in]_yvalue along y
template<typename T>
T ignition::math::Vector2< T >::X ( ) const
inline

Return the x value.

Returns
Value of the X component.
Exceptions
N/A.

Referenced by ignition::math::Line2< T >::CrossProduct(), ignition::math::Line2< T >::Intersect(), and ignition::math::Line2< T >::Within().

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

Return a mutable x value.

Returns
Value of the X component.
Exceptions
N/A.
template<typename T>
void ignition::math::Vector2< T >::X ( const T &  _v)
inline

Set the x value.

Parameters
[in]_vValue for the x component.
template<typename T>
T ignition::math::Vector2< T >::Y ( ) const
inline

Return the y value.

Returns
Value of the Y component.
Exceptions
N/A.

Referenced by ignition::math::Line2< T >::CrossProduct(), ignition::math::Line2< T >::Intersect(), and ignition::math::Line2< T >::Within().

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

Return a mutable y value.

Returns
Value of the Y component.
Exceptions
N/A.
template<typename T>
void ignition::math::Vector2< T >::Y ( const T &  _v)
inline

Set the y value.

Parameters
[in]_vValue for the y component.

Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< ( std::ostream &  _out,
const Vector2< T > &  _pt 
)
friend

Stream extraction operator.

Parameters
[in]_outoutput stream
[in]_ptVector2 to output
Returns
The stream
Exceptions
N/A.
template<typename T>
std::istream& operator>> ( std::istream &  _in,
Vector2< T > &  _pt 
)
friend

Stream extraction operator.

Parameters
[in]_ininput stream
[in]_ptVector2 to read values into
Returns
The stream
Exceptions
N/A.

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