All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
gazebo::math::Vector3 Class Reference

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

#include <Vector3.hh>

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

double x
 X location.
 
double y
 Y location.
 
double z
 Z location.
 

Friends

std::ostream & operator<< (std::ostream &_out, const gazebo::math::Vector3 &_pt)
 Stream insertion operator.
 
std::istream & operator>> (std::istream &_in, gazebo::math::Vector3 &_pt)
 Stream extraction operator.
 

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

gazebo::math::Vector3::Vector3 ( )

Constructor.

Referenced by operator-().

gazebo::math::Vector3::Vector3 ( const double &  _x,
const double &  _y,
const double &  _z 
)

Constructor.

Parameters
[in]_xvalue along x
[in]_yvalue along y
[in]_zvalue along z
gazebo::math::Vector3::Vector3 ( const Vector3 _v)

Copy constructor.

Parameters
[in]_va vector
virtual gazebo::math::Vector3::~Vector3 ( )
virtual

Destructor.

Member Function Documentation

void gazebo::math::Vector3::Correct ( )
inline

Corrects any nan values.

References x, y, and z.

Referenced by gazebo::math::Pose::Correct().

Vector3 gazebo::math::Vector3::Cross ( const Vector3 _pt) const

Return the cross product of this vector and pt.

Returns
the product
double gazebo::math::Vector3::Distance ( const Vector3 _pt) const

Calc distance to the given point.

Parameters
[in]_ptthe point
Returns
the distance
double gazebo::math::Vector3::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
double gazebo::math::Vector3::Dot ( const Vector3 _pt) const

Return the dot product of this vector and pt.

Returns
the product
bool gazebo::math::Vector3::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
Vector3 gazebo::math::Vector3::GetAbs ( ) const

Get the absolute value of the vector.

Returns
a vector with positive elements
double gazebo::math::Vector3::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
double gazebo::math::Vector3::GetLength ( ) const

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

double gazebo::math::Vector3::GetMax ( ) const

Get the maximum value in the vector.

Returns
the maximum element
double gazebo::math::Vector3::GetMin ( ) const

Get the minimum value in the vector.

Returns
the minimum element
static Vector3 gazebo::math::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
Vector3 gazebo::math::Vector3::GetPerpendicular ( ) const

Return a vector that is perpendicular to this one.

Returns
an orthogonal vector
Vector3 gazebo::math::Vector3::GetRounded ( ) const

Get a rounded version of this vector.

Returns
a rounded vector
double gazebo::math::Vector3::GetSquaredLength ( ) const

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

Returns
the lenght
double gazebo::math::Vector3::GetSum ( ) const

Return the sum of the values.

Returns
the sum
bool gazebo::math::Vector3::IsFinite ( ) const

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

Vector3 gazebo::math::Vector3::Normalize ( )

Normalize the vector length.

Returns
unit length vector
bool gazebo::math::Vector3::operator!= ( const Vector3 _v) const

Not equal to operator.

Parameters
[in]_va vector
Returns
true if each component is equal withing a default tolerence (1e-6), false otherwise
Vector3 gazebo::math::Vector3::operator* ( const Vector3 _p) const

Multiplication operator.

Remarks
this is an element wise multiplication, not a cross product
Parameters
[in]_v
Vector3 gazebo::math::Vector3::operator* ( double  _v) const

Multiplication operators.

Parameters
[in]_vthe scaling factor
Returns
a scaled vector
const Vector3& gazebo::math::Vector3::operator*= ( const Vector3 _v)

Multiplication operators.

Remarks
this is an element wise multiplication, not a cross product
Parameters
[in]_va vector
Returns
this
const Vector3& gazebo::math::Vector3::operator*= ( double  _v)

Multiplication operator.

Parameters
[in]_vscaling factor
Returns
this
Vector3 gazebo::math::Vector3::operator+ ( const Vector3 _v) const

Addition operator.

Parameters
[in]_vvector to add
Returns
the sum vector
const Vector3& gazebo::math::Vector3::operator+= ( const Vector3 _v)

Addition assignment operator.

Parameters
[in]_vvector to add
Vector3 gazebo::math::Vector3::operator- ( const Vector3 _pt) const
inline

Subtraction operators.

Parameters
[in]_pta vector to substract
Returns
a vector

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

const Vector3& gazebo::math::Vector3::operator-= ( const Vector3 _pt)

Subtraction operators.

const Vector3 gazebo::math::Vector3::operator/ ( const Vector3 _pt) const

Division operator.

Remarks
this is an element wise division
Returns
a vector
const Vector3 gazebo::math::Vector3::operator/ ( double  _v) const

Division operator.

Remarks
this is an element wise division
Returns
a vector
const Vector3& gazebo::math::Vector3::operator/= ( const Vector3 _pt)

Division assignment operator.

Remarks
this is an element wise division
Returns
a vector
const Vector3& gazebo::math::Vector3::operator/= ( double  _v)

Division operator.

Remarks
this is an element wise division
Returns
this
Vector3& gazebo::math::Vector3::operator= ( const Vector3 _v)

Assignment operator.

Parameters
[in]_va new value
Returns
this
Vector3& gazebo::math::Vector3::operator= ( double  _value)

Assignment operator.

Parameters
[in]_valueassigned to all elements
Returns
this
bool gazebo::math::Vector3::operator== ( const Vector3 _pt) const

Equal to operator.

Returns
true if each component is equal withing a default tolerence (1e-6), false otherwise
double gazebo::math::Vector3::operator[] ( unsigned int  index) const

[] operator

Vector3 gazebo::math::Vector3::Round ( )

Round to near whole number, return the result.

Returns
the result
void gazebo::math::Vector3::Round ( int  _precision)

Round all values to _precision decimal places.

Parameters
[in]_precisionthe decimal places
void gazebo::math::Vector3::Set ( double  _x = 0,
double  _y = 0,
double  _z = 0 
)
inline

Set the contents of the vector.

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

References x, y, and z.

void gazebo::math::Vector3::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
void gazebo::math::Vector3::SetToMin ( const Vector3 _v)

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

Parameters
[in]theminimumn clamping vector

Friends And Related Function Documentation

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

Stream insertion operator.

Parameters
_outoutput stream
_ptVector3 to output
Returns
the stream
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

double gazebo::math::Vector3::x
double gazebo::math::Vector3::y
double gazebo::math::Vector3::z

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