Gazebo Math

API Reference

8.1.0

The CoordinateVector3 class represents the vector containing 3 coordinates, either metric or spherical. More...

#include <gz/math/CoordinateVector3.hh>

Public Member Functions

 CoordinateVector3 ()
 Construct an empty metric vector.
 
 CoordinateVector3 (const CoordinateVector3 &_other)
 Copy constructor.
 
 CoordinateVector3 (CoordinateVector3 &&_other) noexcept
 
 ~CoordinateVector3 ()
 
std::optional< math::Vector3dAsMetricVector () const
 Return this vector as a metric Vector3d (only valid for metric).
 
bool Equal (const CoordinateVector3 &_v) const
 Equality test.
 
bool Equal (const CoordinateVector3 &_v, const double &_tol, const math::Angle &_ang_tol) const
 Equality test with tolerance.
 
bool IsFinite () const
 See if all vector components are finite (e.g., not nan)
 
bool IsMetric () const
 Whether this vector is metric.
 
bool IsSpherical () const
 Whether this vector is spherical.
 
std::optional< math::AngleLat () const
 Get the latitude of a spherical vector.
 
bool Lat (const Angle &_v)
 Set the latitude.
 
std::optional< math::AngleLon () const
 Get the longitude of a spherical vector.
 
bool Lon (const Angle &_v)
 Set the longitude.
 
bool operator!= (const CoordinateVector3 &_v) const
 Not equal to operator.
 
CoordinateVector3 operator+ (const CoordinateVector3 &_v) const
 Addition operator.
 
const CoordinateVector3operator+= (const CoordinateVector3 &_v)
 Addition assignment operator.
 
CoordinateVector3 operator- () const
 Negation operator.
 
CoordinateVector3 operator- (const CoordinateVector3 &_pt) const
 Subtraction operators.
 
const CoordinateVector3operator-= (const CoordinateVector3 &_pt)
 Subtraction assignment operators.
 
CoordinateVector3operator= (const CoordinateVector3 &_other)
 Copy assignment.
 
CoordinateVector3operator= (CoordinateVector3 &&_other) noexcept
 Move assignment.
 
bool operator== (const CoordinateVector3 &_v) const
 Equal to operator.
 
void SetMetric (const math::Vector3d &_v)
 Set the metric contents of the vector.
 
void SetMetric (double _x, double _y, double _z)
 Set the metric contents of the vector.
 
void SetSpherical (const math::Angle &_lat, const math::Angle &_lon, double _z)
 Set the spherical contents of the vector.
 
std::optional< doubleX () const
 Get the x value of a metric vector.
 
bool X (const double &_v)
 Set the x value.
 
std::optional< doubleY () const
 Get the y value of a metric vector.
 
bool Y (const double &_v)
 Set the y value.
 
std::optional< doubleZ () const
 Get the z value.
 
bool Z (const double &_v)
 Set the z value.
 

Static Public Member Functions

static CoordinateVector3 Metric (const math::Vector3d &_v)
 Constructor for metric values.
 
static CoordinateVector3 Metric (double _x, double _y, double _z)
 Constructor for metric values.
 
static CoordinateVector3 Spherical (const math::Angle &_lat, const math::Angle &_lon, double _z)
 Constructor for spherical values.
 

Detailed Description

The CoordinateVector3 class represents the vector containing 3 coordinates, either metric or spherical.

Constructor & Destructor Documentation

◆ CoordinateVector3() [1/3]

Construct an empty metric vector.

◆ ~CoordinateVector3()

◆ CoordinateVector3() [2/3]

Copy constructor.

Parameters
[in]_otherThe copied value.

◆ CoordinateVector3() [3/3]

CoordinateVector3 ( CoordinateVector3 &&  _other)
noexcept

Member Function Documentation

◆ AsMetricVector()

std::optional< math::Vector3d > AsMetricVector ( ) const

Return this vector as a metric Vector3d (only valid for metric).

Returns
The metric vector (or nullopt if the vector is not metric).

◆ Equal() [1/2]

bool Equal ( const CoordinateVector3 _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

◆ Equal() [2/2]

bool Equal ( const CoordinateVector3 _v,
const double _tol,
const math::Angle _ang_tol 
) const

Equality test with tolerance.

Parameters
[in]_vthe vector to compare to
[in]_tolequality tolerance for metric components.
[in]_ang_tolequality tolerance for spherical components.
Returns
true if the vectors are equal within the tolerance specified by _tol and _ang_tol.

◆ IsFinite()

bool IsFinite ( ) const

See if all vector components are finite (e.g., not nan)

Returns
true if is finite or false otherwise

◆ IsMetric()

bool IsMetric ( ) const

Whether this vector is metric.

Returns
Whether this vector is metric.

◆ IsSpherical()

bool IsSpherical ( ) const

Whether this vector is spherical.

Returns
Whether this vector is spherical.

◆ Lat() [1/2]

std::optional< math::Angle > Lat ( ) const

Get the latitude of a spherical vector.

Returns
The latitude of the spherical vector (or nullopt if metric).

◆ Lat() [2/2]

bool Lat ( const Angle _v)

Set the latitude.

Parameters
[in]_vValue for the latitude.
Returns
True if the vector is spherical, false otherwise.

◆ Lon() [1/2]

std::optional< math::Angle > Lon ( ) const

Get the longitude of a spherical vector.

Returns
The longitude of the spherical vector (or nullopt if metric).

◆ Lon() [2/2]

bool Lon ( const Angle _v)

Set the longitude.

Parameters
[in]_vValue for the longitude.
Returns
True if the vector is spherical, false otherwise.

◆ Metric() [1/2]

static CoordinateVector3 Metric ( const math::Vector3d _v)
static

Constructor for metric values.

Parameters
[in]_vThe metric vector.
Returns
The coordinate vector.

◆ Metric() [2/2]

static CoordinateVector3 Metric ( double  _x,
double  _y,
double  _z 
)
static

Constructor for metric values.

Parameters
[in]_xvalue along x
[in]_yvalue along y
[in]_zvalue along z
Returns
The coordinate vector.

◆ operator!=()

bool operator!= ( const CoordinateVector3 _v) const

Not equal to operator.

Parameters
[in]_vThe vector to compare against
Returns
false if the vectors are not equal within a default tolerance (1e-3), true otherwise

◆ operator+()

Addition operator.

Parameters
[in]_vvector to add
Returns
the sum vector
Note
If one vector is metric and the other is spherical, a NaN vector will be returned and a message logged to cerr.

◆ operator+=()

Addition assignment operator.

Parameters
[in]_vvector to add
Returns
the sum vector
Note
If one vector is metric and the other is spherical, a NaN vector will be set and a message logged to cerr.

◆ operator-() [1/2]

Negation operator.

Returns
negative of this vector

◆ operator-() [2/2]

Subtraction operators.

Parameters
[in]_pta vector to subtract
Returns
a vector after the subtraction
Note
If one vector is metric and the other is spherical, a NaN vector will be returned and a message logged to cerr.

◆ operator-=()

Subtraction assignment operators.

Parameters
[in]_ptsubtrahend
Returns
a vector after the subtraction
Note
If one vector is metric and the other is spherical, a NaN vector will be set and a message logged to cerr.

◆ operator=() [1/2]

Copy assignment.

Parameters
[in]_otherThe copied value.
Returns
Reference to this.

◆ operator=() [2/2]

CoordinateVector3 & operator= ( CoordinateVector3 &&  _other)
noexcept

Move assignment.

Parameters
[in]_otherThe copied value.
Returns
Reference to this.

◆ operator==()

bool operator== ( const CoordinateVector3 _v) const

Equal to operator.

Parameters
[in]_vThe vector to compare against
Returns
true if the vectors are equal within a default tolerance (1e-3), false otherwise

◆ SetMetric() [1/2]

void SetMetric ( const math::Vector3d _v)

Set the metric contents of the vector.

Parameters
[in]_vThe metric vector.

◆ SetMetric() [2/2]

void SetMetric ( double  _x,
double  _y,
double  _z 
)

Set the metric contents of the vector.

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

◆ SetSpherical()

void SetSpherical ( const math::Angle _lat,
const math::Angle _lon,
double  _z 
)

Set the spherical contents of the vector.

Parameters
[in]_latlatitude value
[in]_lonlongitude value
[in]_zvalue along z

◆ Spherical()

static CoordinateVector3 Spherical ( const math::Angle _lat,
const math::Angle _lon,
double  _z 
)
static

Constructor for spherical values.

Parameters
[in]_latlatitude value
[in]_lonlongitude value
[in]_zvalue along z
Returns
The coordinate vector.

◆ X() [1/2]

std::optional< double > X ( ) const

Get the x value of a metric vector.

Returns
The x component of the metric vector (or nullopt if spherical).

◆ X() [2/2]

bool X ( const double _v)

Set the x value.

Parameters
[in]_vValue for the x component.
Returns
True if the vector is metric, false otherwise.

◆ Y() [1/2]

std::optional< double > Y ( ) const

Get the y value of a metric vector.

Returns
The y component of the metric vector (or nullopt if spherical).

◆ Y() [2/2]

bool Y ( const double _v)

Set the y value.

Parameters
[in]_vValue for the y component.
Returns
True if the vector is metric, false otherwise.

◆ Z() [1/2]

std::optional< double > Z ( ) const

Get the z value.

Returns
The z component of the vector (nullopt is never returned).

◆ Z() [2/2]

bool Z ( const double _v)

Set the z value.

Parameters
[in]_vValue for the z component.
Returns
Always true.

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