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

The Vector3 class represents the generic vector containing 3 elements. More...

#include <ignition/math/Vector3.hh>

Public Member Functions

 Vector3 ()
 Constructor. More...
 
 Vector3 (const T &_x, const T &_y, const T &_z)
 Constructor. More...
 
 Vector3 (const Vector3< T > &_v)
 Copy constructor. More...
 
virtual ~Vector3 ()
 Destructor. More...
 
Vector3 Abs () const
 Get the absolute value of the vector. 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...
 
Distance (const Vector3< T > &_pt) const
 Calc distance to the given point. More...
 
Distance (T _x, T _y, T _z) const
 Calc distance to the given point. More...
 
DistToLine (const Vector3< T > &_pt1, const Vector3 &_pt2)
 Get distance to a line. More...
 
Dot (const Vector3< T > &_v) const
 Return the dot product of this vector and another vector. 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...
 
Length () const
 Returns the length (magnitude) of the vector \ return the length. More...
 
void Max (const Vector3< T > &_v)
 Set this vector's components to the maximum of itself and the passed in vector. More...
 
Max () const
 Get the maximum 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...
 
Min () const
 Get the minimum value in the vector. More...
 
Vector3 Normalize ()
 Normalize the vector length. 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 operator+ (const Vector3< T > &_v) const
 Addition operator. More...
 
const Vector3operator+= (const Vector3< T > &_v)
 Addition assignment operator. More...
 
Vector3 operator- () const
 Negation operator. More...
 
Vector3< T > operator- (const Vector3< T > &_pt) const
 Subtraction operators. 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...
 
Vector3operator= (const Vector3< T > &_v)
 Assignment operator. More...
 
Vector3operator= (T _v)
 Assignment operator. More...
 
bool operator== (const Vector3< T > &_v) const
 Equal to operator. More...
 
operator[] (size_t _index) const
 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...
 
SquaredLength () const
 Return the square of the length (magnitude) of the vector. More...
 
Sum () const
 Return the sum of the values. More...
 
X () const
 Get the x value. More...
 
T & X ()
 Get a mutable reference to the x value. More...
 
void X (const T &_v)
 Set the x value. More...
 
Y () const
 Get the y value. More...
 
T & Y ()
 Get a mutable reference to the y value. More...
 
void Y (const T &_v)
 Set the y value. More...
 
Z () const
 Get the z value. More...
 
T & Z ()
 Get a mutable reference to 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 One
 math::Vector3(1, 1, 1) More...
 
static const Vector3 UnitX
 math::Vector3(1, 0, 0) More...
 
static const Vector3 UnitY
 math::Vector3(0, 1, 0) More...
 
static const Vector3 UnitZ
 math::Vector3(0, 0, 1) More...
 
static const Vector3 Zero
 math::Vector3(0, 0, 0) More...
 

Friends

Vector3< T > operator* (T _s, const Vector3< T > &_v)
 Multiplication operators. More...
 
std::ostream & operator<< (std::ostream &_out, const ignition::math::Vector3< T > &_pt)
 Stream insertion operator. More...
 
std::istream & operator>> (std::istream &_in, ignition::math::Vector3< T > &_pt)
 Stream extraction operator. More...
 

Detailed Description

template<typename T>
class ignition::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

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

Constructor.

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

Copy constructor.

Parameters
[in]_va vector
template<typename T>
virtual ignition::math::Vector3< T >::~Vector3 ( )
inlinevirtual

Destructor.

Member Function Documentation

template<typename T>
Vector3 ignition::math::Vector3< T >::Abs ( ) const
inline

Get the absolute value of the vector.

Returns
a vector with positive elements
template<typename T>
void ignition::math::Vector3< T >::Correct ( )
inline

Corrects any nan values.

template<typename T>
Vector3 ignition::math::Vector3< T >::Cross ( const Vector3< T > &  _v) const
inline

Return the cross product of this vector with another vector.

Parameters
[in]_va vector
Returns
the cross product

Referenced by ignition::math::Vector3< double >::DistToLine(), ignition::math::Vector3< double >::Normal(), ignition::math::Quaternion< T >::operator*(), and ignition::math::Vector3< double >::Perpendicular().

template<typename T>
T ignition::math::Vector3< T >::Distance ( const Vector3< T > &  _pt) const
inline

Calc distance to the given point.

Parameters
[in]_ptthe point
Returns
the distance

Referenced by ignition::math::Vector3< double >::Distance().

template<typename T>
T ignition::math::Vector3< T >::Distance ( _x,
_y,
_z 
) const
inline

Calc distance to the given point.

Parameters
[in]_xvalue along x
[in]_yvalue along y
[in]_zvalue along z
Returns
the distance
template<typename T>
T ignition::math::Vector3< T >::DistToLine ( const Vector3< T > &  _pt1,
const Vector3< T > &  _pt2 
)
inline

Get distance to a line.

Parameters
[in]_pt1first point on the line
[in]_pt2second point on the line
Returns
the minimum distance from this point to the line
template<typename T>
T ignition::math::Vector3< T >::Dot ( const Vector3< T > &  _v) const
inline

Return the dot product of this vector and another vector.

Parameters
[in]_vthe vector
Returns
the dot product

Referenced by ignition::math::Plane< T >::Distance().

template<typename T>
bool ignition::math::Vector3< T >::Equal ( const Vector3< T > &  _v) const
inline

Equality test.

Remarks
This is equivalent to the == operator
Parameters
[in]_vthe other vector
Returns
true if the 2 vectors have the same values, false otherwise
template<typename T>
bool ignition::math::Vector3< T >::IsFinite ( ) const
inline

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

Returns
true if is finite or false otherwise
template<typename T>
T ignition::math::Vector3< T >::Length ( ) const
inline

Returns the length (magnitude) of the vector \ return the length.

Referenced by ignition::math::Vector3< double >::DistToLine().

template<typename T>
void ignition::math::Vector3< T >::Max ( const Vector3< T > &  _v)
inline

Set this vector's components to the maximum of itself and the passed in vector.

Parameters
[in]_vthe maximum clamping vector
template<typename T>
T ignition::math::Vector3< T >::Max ( ) const
inline

Get the maximum value in the vector.

Returns
the maximum element
template<typename T>
void ignition::math::Vector3< T >::Min ( const Vector3< T > &  _v)
inline

Set this vector's components to the minimum of itself and the passed in vector.

Parameters
[in]_vthe minimum clamping vector
template<typename T>
T ignition::math::Vector3< T >::Min ( ) const
inline

Get the minimum value in the vector.

Returns
the minimum element
template<typename T>
static Vector3 ignition::math::Vector3< T >::Normal ( const Vector3< T > &  _v1,
const Vector3< T > &  _v2,
const Vector3< T > &  _v3 
)
inlinestatic

Get a normal vector to a triangle.

Parameters
[in]_v1first vertex of the triangle
[in]_v2second vertex
[in]_v3third vertex
Returns
the normal
template<typename T>
Vector3 ignition::math::Vector3< T >::Normalize ( )
inline

Normalize the vector length.

Returns
unit length vector
template<typename T>
bool ignition::math::Vector3< T >::operator!= ( const Vector3< T > &  _v) const
inline

Not equal to operator.

Parameters
[in]_vThe vector to compare against
Returns
true if each component is equal withing a default tolerence (1e-6), false otherwise
template<typename T>
Vector3<T> ignition::math::Vector3< T >::operator* ( const Vector3< T > &  _p) const
inline

Multiplication operator.

Remarks
this is an element wise multiplication, not a cross product
Parameters
[in]_pmultiplier operator
Returns
a vector
template<typename T>
Vector3<T> ignition::math::Vector3< T >::operator* ( _s) const
inline

Multiplication operators.

Parameters
[in]_sthe scaling factor
Returns
a scaled vector
template<typename T>
const Vector3<T>& ignition::math::Vector3< T >::operator*= ( const Vector3< T > &  _v)
inline

Multiplication assignment operators.

Remarks
this is an element wise multiplication, not a cross product
Parameters
[in]_va vector
Returns
this
template<typename T>
const Vector3<T>& ignition::math::Vector3< T >::operator*= ( _v)
inline

Multiplication operator.

Parameters
[in]_vscaling factor
Returns
this
template<typename T>
Vector3 ignition::math::Vector3< T >::operator+ ( const Vector3< T > &  _v) const
inline

Addition operator.

Parameters
[in]_vvector to add
Returns
the sum vector
template<typename T>
const Vector3& ignition::math::Vector3< T >::operator+= ( const Vector3< T > &  _v)
inline

Addition assignment operator.

Parameters
[in]_vvector to add
Returns
the sum vector
template<typename T>
Vector3 ignition::math::Vector3< T >::operator- ( ) const
inline

Negation operator.

Returns
negative of this vector
template<typename T>
Vector3<T> ignition::math::Vector3< T >::operator- ( const Vector3< T > &  _pt) const
inline

Subtraction operators.

Parameters
[in]_pta vector to substract
Returns
a vector after the substraction
template<typename T>
const Vector3<T>& ignition::math::Vector3< T >::operator-= ( const Vector3< T > &  _pt)
inline

Subtraction assignment operators.

Parameters
[in]_ptsubtrahend
Returns
a vector after the substraction
template<typename T>
const Vector3<T> ignition::math::Vector3< T >::operator/ ( const Vector3< T > &  _pt) const
inline

Division operator.

Remarks
this is an element wise division
Parameters
[in]_ptthe vector divisor
Returns
a vector
template<typename T>
const Vector3<T> ignition::math::Vector3< T >::operator/ ( _v) const
inline

Division operator.

Remarks
this is an element wise division
Parameters
[in]_vthe divisor
Returns
a vector
template<typename T>
const Vector3<T>& ignition::math::Vector3< T >::operator/= ( const Vector3< T > &  _pt)
inline

Division assignment operator.

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

Division assignment operator.

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

Assignment operator.

Parameters
[in]_va new value
Returns
this
template<typename T>
Vector3& ignition::math::Vector3< T >::operator= ( _v)
inline

Assignment operator.

Parameters
[in]_valueassigned to all elements
Returns
this
template<typename T>
bool ignition::math::Vector3< T >::operator== ( const Vector3< T > &  _v) const
inline

Equal to operator.

Parameters
[in]_vThe vector to compare against
Returns
true if each component is equal withing a default tolerence (1e-6), false otherwise
template<typename T>
T ignition::math::Vector3< T >::operator[] ( size_t  _index) const
inline

Array subscript operator.

Parameters
[in]_indexThe index, where 0 == x, 1 == y, 2 == z.
Returns
The value. Throws an IndexException if _index is out of bounds.
Exceptions
IndexExceptionif _index is >= 3.
template<typename T>
Vector3 ignition::math::Vector3< T >::Perpendicular ( ) const
inline

Return a vector that is perpendicular to this one.

Returns
an orthogonal vector
template<typename T>
Vector3 ignition::math::Vector3< T >::Round ( )
inline

Round to near whole number, return the result.

Returns
the result

Referenced by ignition::math::Vector3< double >::Rounded().

template<typename T>
void ignition::math::Vector3< T >::Round ( int  _precision)
inline

Round all values to _precision decimal places.

Parameters
[in]_precisionthe decimal places
template<typename T>
Vector3 ignition::math::Vector3< T >::Rounded ( ) const
inline

Get a rounded version of this vector.

Returns
a rounded vector
template<typename T>
void ignition::math::Vector3< T >::Set ( _x = 0,
_y = 0,
_z = 0 
)
inline

Set the contents of the vector.

Parameters
[in]_xvalue along x
[in]_yvalue along y
[in]_zvalue aling z

Referenced by ignition::math::Quaternion< T >::ToAxis().

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

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

Returns
the squared length

Referenced by ignition::math::Vector3< double >::Perpendicular().

template<typename T>
T ignition::math::Vector3< T >::Sum ( ) const
inline

Return the sum of the values.

Returns
the sum
template<typename T>
T ignition::math::Vector3< T >::X ( ) const
inline
template<typename T>
T& ignition::math::Vector3< T >::X ( )
inline

Get a mutable reference to the x value.

Returns
The x component of the vector
template<typename T>
void ignition::math::Vector3< T >::X ( const T &  _v)
inline

Set the x value.

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

Get a mutable reference to the y value.

Returns
The y component of the vector
template<typename T>
void ignition::math::Vector3< T >::Y ( const T &  _v)
inline

Set the y value.

Parameters
[in]_vValue for the y component.
template<typename T>
T ignition::math::Vector3< T >::Z ( ) const
inline
template<typename T>
T& ignition::math::Vector3< T >::Z ( )
inline

Get a mutable reference to the z value.

Returns
The z component of the vector
template<typename T>
void ignition::math::Vector3< T >::Z ( const T &  _v)
inline

Set the z value.

Parameters
[in]_vValue for the z component.

Friends And Related Function Documentation

template<typename T>
Vector3<T> operator* ( _s,
const Vector3< T > &  _v 
)
friend

Multiplication operators.

Parameters
[in]_sthe scaling factor
[in]_vinput vector
Returns
a scaled vector
template<typename T>
std::ostream& operator<< ( std::ostream &  _out,
const ignition::math::Vector3< T > &  _pt 
)
friend

Stream insertion operator.

Parameters
_outoutput stream
_ptVector3 to output
Returns
the stream
template<typename T>
std::istream& operator>> ( std::istream &  _in,
ignition::math::Vector3< T > &  _pt 
)
friend

Stream extraction operator.

Parameters
_ininput stream
_ptvector3 to read values into
Returns
the stream

Member Data Documentation

template<typename T>
const Vector3< T > ignition::math::Vector3< T >::One
static

math::Vector3(1, 1, 1)

template<typename T>
const Vector3< T > ignition::math::Vector3< T >::UnitX
static

math::Vector3(1, 0, 0)

template<typename T>
const Vector3< T > ignition::math::Vector3< T >::UnitY
static

math::Vector3(0, 1, 0)

template<typename T>
const Vector3< T > ignition::math::Vector3< T >::UnitZ
static

math::Vector3(0, 0, 1)

template<typename T>
const Vector3< T > ignition::math::Vector3< T >::Zero
static

math::Vector3(0, 0, 0)


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