Vector3 Class Reference

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

#include <math/gzmath.hh>

Public Member Functions

 Vector3 ()
 Constructor. More...
 
 Vector3 (const double &_x, const double &_y, const double &_z)
 Constructor. More...
 
 Vector3 (const ignition::math::Vector3d &_v)
 Ignition math copy constructor. More...
 
 Vector3 (const Vector3 &_v)
 Copy constructor. More...
 
virtual ~Vector3 ()
 Destructor. More...
 
void Correct ()
 Corrects any nan values. More...
 
Vector3 Cross (const Vector3 &_pt) const
 Return the cross product of this vector and pt. More...
 
double Distance (const Vector3 &_pt) const
 Calc distance to the given point. More...
 
double Distance (double _x, double _y, double _z) const
 Calc distance to the given point. More...
 
double Dot (const Vector3 &_pt) const
 Return the dot product of this vector and pt. More...
 
bool Equal (const Vector3 &_v) const
 Equality test. More...
 
Vector3 GetAbs () const
 Get the absolute value of the vector. More...
 
double GetDistToLine (const Vector3 &_pt1, const Vector3 &_pt2)
 Get distance to a line. More...
 
double GetLength () const
 Returns the length (magnitude) of the vector \ return the length. More...
 
double GetMax () const
 Get the maximum value in the vector. More...
 
double GetMin () const
 Get the minimum value in the vector. More...
 
Vector3 GetPerpendicular () const
 Return a vector that is perpendicular to this one. More...
 
Vector3 GetRounded () const
 Get a rounded version of this vector. More...
 
double GetSquaredLength () const
 Return the square of the length (magnitude) of the vector. More...
 
double GetSum () const
 Return the sum of the values. More...
 
ignition::math::Vector3d Ign () const
 Convert this vector to an ignition::math::Vector3d. More...
 
bool IsFinite () const
 See if a point is finite (e.g., not nan) More...
 
Vector3 Normalize ()
 Normalize the vector length. More...
 
bool operator!= (const Vector3 &_v) const
 Not equal to operator. More...
 
Vector3 operator* (const Vector3 &_p) const
 Multiplication operator. More...
 
Vector3 operator* (double _v) const
 Multiplication operators. More...
 
const Vector3operator*= (const Vector3 &_v)
 Multiplication operators. More...
 
const Vector3operator*= (double _v)
 Multiplication operator. More...
 
Vector3 operator+ (const Vector3 &_v) const
 Addition operator. More...
 
const Vector3operator+= (const Vector3 &_v)
 Addition assignment operator. More...
 
Vector3 operator- () const
 Negation operator. More...
 
Vector3 operator- (const Vector3 &_pt) const
 Subtraction operators. More...
 
const Vector3operator-= (const Vector3 &_pt)
 Subtraction operators. More...
 
const Vector3 operator/ (const Vector3 &_pt) const
 Division operator. More...
 
const Vector3 operator/ (double _v) const
 Division operator. More...
 
const Vector3operator/= (const Vector3 &_pt)
 Division assignment operator. More...
 
const Vector3operator/= (double _v)
 Division operator. More...
 
Vector3operator= (const ignition::math::Vector3d &_v)
 Assignment operator for ignition math. More...
 
Vector3operator= (const Vector3 &_v)
 Assignment operator. More...
 
Vector3operator= (double _value)
 Assignment operator. More...
 
bool operator== (const Vector3 &_pt) const
 Equal to operator. More...
 
double operator[] (unsigned int index) const
 [] operator More...
 
Vector3 Round ()
 Round to near whole number, return the result. More...
 
void Round (int _precision)
 Round all values to _precision decimal places. More...
 
void Set (double _x=0, double _y=0, double _z=0)
 Set the contents of the vector. More...
 
void SetToMax (const Vector3 &_v)
 Set this vector's components to the maximum of itself and the passed in vector. More...
 
void SetToMin (const Vector3 &_v)
 Set this vector's components to the minimum of itself and the passed in vector. More...
 

Static Public Member Functions

static Vector3 GetNormal (const Vector3 &_v1, const Vector3 &_v2, const Vector3 &_v3)
 Get a normal vector to a triangle. More...
 

Public Attributes

double x
 X location. More...
 
double y
 Y location. More...
 
double z
 Z location. 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 operator* (double _s, const Vector3 &_v)
 Multiplication operators. More...
 
std::ostream & operator<< (std::ostream &_out, const gazebo::math::Vector3 &_pt)
 Stream insertion operator. More...
 
std::istream & operator>> (std::istream &_in, gazebo::math::Vector3 &_pt)
 Stream extraction operator. More...
 

Detailed Description

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/4]

Vector3 ( )

Constructor.

Referenced by Vector3::operator-().

§ Vector3() [2/4]

Vector3 ( const double &  _x,
const double &  _y,
const double &  _z 
)

Constructor.

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

§ Vector3() [3/4]

Vector3 ( const ignition::math::Vector3d &  _v)

Ignition math copy constructor.

Parameters
[in]_va vector

§ Vector3() [4/4]

Vector3 ( const Vector3 _v)

Copy constructor.

Parameters
[in]_va vector

§ ~Vector3()

virtual ~Vector3 ( )
virtual

Destructor.

Member Function Documentation

§ Correct()

void Correct ( )
inline

Corrects any nan values.

References Vector3::Equal(), Vector3::operator[](), Vector3::Round(), Vector3::x, Vector3::y, and Vector3::z.

Referenced by Pose::Correct().

§ Cross()

Vector3 Cross ( const Vector3 _pt) const

Return the cross product of this vector and pt.

Returns
the product

Referenced by Vector3::Set().

§ Distance() [1/2]

double Distance ( const Vector3 _pt) const

Calc distance to the given point.

Parameters
[in]_ptthe point
Returns
the distance

§ Distance() [2/2]

double Distance ( double  _x,
double  _y,
double  _z 
) const

Calc distance to the given point.

Parameters
[in]_xvalue along x
[in]_yvalue along y
[in]_zvalue along z
Returns
the distance

§ Dot()

double Dot ( const Vector3 _pt) const

Return the dot product of this vector and pt.

Returns
the product

Referenced by Vector3::Set().

§ Equal()

bool Equal ( const Vector3 _v) const

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

Referenced by Vector3::Correct().

§ GetAbs()

Vector3 GetAbs ( ) const

Get the absolute value of the vector.

Returns
a vector with positive elements

Referenced by Vector3::Set().

§ GetDistToLine()

double GetDistToLine ( const Vector3 _pt1,
const Vector3 _pt2 
)

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

Referenced by Vector3::Set().

§ GetLength()

double GetLength ( ) const

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

§ GetMax()

double GetMax ( ) const

Get the maximum value in the vector.

Returns
the maximum element

Referenced by Vector3::Set().

§ GetMin()

double GetMin ( ) const

Get the minimum value in the vector.

Returns
the minimum element

Referenced by Vector3::Set().

§ GetNormal()

static Vector3 GetNormal ( const Vector3 _v1,
const Vector3 _v2,
const Vector3 _v3 
)
static

Get a normal vector to a triangle.

Parameters
[in]_v1first vertex of the triangle
[in]_v2second vertex
[in]_v3third vertex
Returns
the normal

Referenced by Vector3::Set().

§ GetPerpendicular()

Vector3 GetPerpendicular ( ) const

Return a vector that is perpendicular to this one.

Returns
an orthogonal vector

Referenced by Vector3::Set().

§ GetRounded()

Vector3 GetRounded ( ) const

Get a rounded version of this vector.

Returns
a rounded vector

§ GetSquaredLength()

double GetSquaredLength ( ) const

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

Returns
the squared length

§ GetSum()

double GetSum ( ) const

Return the sum of the values.

Returns
the sum

§ Ign()

ignition::math::Vector3d Ign ( ) const

Convert this vector to an ignition::math::Vector3d.

Returns
This vector as an ignition::math::Vector3d.

Referenced by Vector3::Set().

§ IsFinite()

bool IsFinite ( ) const

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

§ Normalize()

Vector3 Normalize ( )

Normalize the vector length.

Returns
unit length vector

§ operator!=()

bool operator!= ( const Vector3 _v) const

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

§ operator*() [1/2]

Vector3 operator* ( const Vector3 _p) const

Multiplication operator.

Remarks
this is an element wise multiplication, not a cross product
Parameters
[in]_v

Referenced by Vector3::operator-().

§ operator*() [2/2]

Vector3 operator* ( double  _v) const

Multiplication operators.

Parameters
[in]_vthe scaling factor
Returns
a scaled vector

§ operator*=() [1/2]

const Vector3& operator*= ( const Vector3 _v)

Multiplication operators.

Remarks
this is an element wise multiplication, not a cross product
Parameters
[in]_va vector
Returns
this

Referenced by Vector3::operator-().

§ operator*=() [2/2]

const Vector3& operator*= ( double  _v)

Multiplication operator.

Parameters
[in]_vscaling factor
Returns
this

§ operator+()

Vector3 operator+ ( const Vector3 _v) const

Addition operator.

Parameters
[in]_vvector to add
Returns
the sum vector

Referenced by Vector3::Set().

§ operator+=()

const Vector3& operator+= ( const Vector3 _v)

Addition assignment operator.

Parameters
[in]_vvector to add

Referenced by Vector3::Set().

§ operator-() [1/2]

Vector3 operator- ( ) const
inline

Negation operator.

Returns
negative of this vector

References Vector3::Vector3(), Vector3::x, Vector3::y, and Vector3::z.

§ operator-() [2/2]

Vector3 operator- ( const Vector3 _pt) const
inline

Subtraction operators.

Parameters
[in]_pta vector to substract
Returns
a vector

References Vector3::operator*(), Vector3::operator*=(), Vector3::operator-=(), Vector3::operator/(), Vector3::operator/=(), Vector3::Vector3(), Vector3::x, Vector3::y, and Vector3::z.

§ operator-=()

const Vector3& operator-= ( const Vector3 _pt)

Subtraction operators.

Parameters
[in]_ptsubtrahend

Referenced by Vector3::operator-().

§ operator/() [1/2]

const Vector3 operator/ ( const Vector3 _pt) const

Division operator.

[in] _pt the vector divisor

Remarks
this is an element wise division
Returns
a vector

Referenced by Vector3::operator-().

§ operator/() [2/2]

const Vector3 operator/ ( double  _v) const

Division operator.

Remarks
this is an element wise division
Returns
a vector

§ operator/=() [1/2]

const Vector3& operator/= ( const Vector3 _pt)

Division assignment operator.

[in] _pt the vector divisor

Remarks
this is an element wise division
Returns
a vector

Referenced by Vector3::operator-().

§ operator/=() [2/2]

const Vector3& operator/= ( double  _v)

Division operator.

Remarks
this is an element wise division
Returns
this

§ operator=() [1/3]

Vector3& operator= ( const ignition::math::Vector3d &  _v)

Assignment operator for ignition math.

Parameters
[in]_va new value
Returns
this

Referenced by Vector3::Set().

§ operator=() [2/3]

Vector3& operator= ( const Vector3 _v)

Assignment operator.

Parameters
[in]_va new value
Returns
The new vector

§ operator=() [3/3]

Vector3& operator= ( double  _value)

Assignment operator.

Parameters
[in]_valueassigned to all elements
Returns
this

§ operator==()

bool operator== ( const Vector3 _pt) const

Equal to operator.

Parameters
[in]_ptThe vector to compare against
Returns
true if each component is equal withing a default tolerence (1e-6), false otherwise

§ operator[]()

double operator[] ( unsigned int  index) const

[] operator

Referenced by Vector3::Correct().

§ Round() [1/2]

Vector3 Round ( )

Round to near whole number, return the result.

Returns
the result

Referenced by Vector3::Correct().

§ Round() [2/2]

void Round ( int  _precision)

Round all values to _precision decimal places.

Parameters
[in]_precisionthe decimal places

§ Set()

void Set ( double  _x = 0,
double  _y = 0,
double  _z = 0 
)
inline

§ SetToMax()

void SetToMax ( const Vector3 _v)

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

Parameters
[in]_vthe maximum clamping vector

Referenced by Vector3::Set().

§ SetToMin()

void SetToMin ( const Vector3 _v)

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

Parameters
[in]_vthe minimum clamping vector

Referenced by Vector3::Set().

Friends And Related Function Documentation

§ operator*

Vector3 operator* ( double  _s,
const Vector3 _v 
)
friend

Multiplication operators.

Parameters
[in]_sthe scaling factor
[in]_vinput vector
Returns
a scaled vector

§ operator<<

std::ostream& operator<< ( std::ostream &  _out,
const gazebo::math::Vector3 _pt 
)
friend

Stream insertion operator.

Parameters
_outoutput stream
_ptVector3 to output
Returns
the stream

§ operator>>

std::istream& operator>> ( std::istream &  _in,
gazebo::math::Vector3 _pt 
)
friend

Stream extraction operator.

Parameters
_ininput stream
_ptvector3 to read values into
Returns
the stream

Member Data Documentation

§ One

const Vector3 One
static

math::Vector3(1, 1, 1)

§ UnitX

const Vector3 UnitX
static

math::Vector3(1, 0, 0)

§ UnitY

const Vector3 UnitY
static

math::Vector3(0, 1, 0)

§ UnitZ

const Vector3 UnitZ
static

math::Vector3(0, 0, 1)

Referenced by ServerFixture::CheckPointer().

§ x

§ y

§ z

§ Zero

const Vector3 Zero
static

math::Vector3(0, 0, 0)

Referenced by Link::GetWorldLinearVel().


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