Gazebo Math

API Reference

8.1.0
Capsule< Precision > Class Template Reference

A representation of a capsule or sphere-capped cylinder. More...

#include <gz/math/Capsule.hh>

Public Member Functions

 Capsule ()=default
 Default constructor. The default radius and length are both zero.
 
 Capsule (const Precision _length, const Precision _radius)
 Construct a capsule with a length and radius.
 
 Capsule (const Precision _length, const Precision _radius, const Material &_mat)
 Construct a capsule with a length, radius, and material.
 
Precision DensityFromMass (const Precision _mass) const
 Compute the capsule's density given a mass value. The capsule is assumed to be solid with uniform density. This function requires the capsule's radius and length to be set to values greater than zero. The Material of the capsule is ignored.
 
Precision Length () const
 Get the length in meters.
 
std::optional< MassMatrix3< Precision > > MassMatrix () const
 Get the mass matrix for this capsule. This function is only meaningful if the capsule's radius, length, and material have been set.
 
const MaterialMat () const
 Get the material associated with this capsule.
 
bool operator== (const Capsule &_capsule) const
 Check if this capsule is equal to the provided capsule. Radius, length, and material properties will be checked.
 
Precision Radius () const
 Get the radius in meters.
 
bool SetDensityFromMass (const Precision _mass)
 Set the density of this capsule based on a mass value. Density is computed using Precision DensityFromMass(const Precision _mass) const. The capsule is assumed to be solid with uniform density. This function requires the capsule's radius and length to be set to values greater than zero. The existing Material density value is overwritten only if the return value from this true.
 
void SetLength (const Precision _length)
 Set the length in meters.
 
void SetMat (const Material &_mat)
 Set the material associated with this capsule.
 
void SetRadius (const Precision _radius)
 Set the radius in meters.
 
Precision Volume () const
 Get the volume of the capsule in m^3.
 

Detailed Description

template<typename Precision>
class gz::math::Capsule< Precision >

A representation of a capsule or sphere-capped cylinder.

The capsule class supports defining a capsule with a radius, length, and material properties. The shape is equivalent to a cylinder aligned with the Z-axis and capped with hemispheres. Radius and length are in meters. See Material for more on material properties.

Template Parameters
PrecisionScalar numeric type.

Constructor & Destructor Documentation

◆ Capsule() [1/3]

template<typename Precision >
Capsule ( )
default

Default constructor. The default radius and length are both zero.

◆ Capsule() [2/3]

template<typename Precision >
Capsule ( const Precision  _length,
const Precision  _radius 
)

Construct a capsule with a length and radius.

Parameters
[in]_lengthLength of the capsule.
[in]_radiusRadius of the capsule.

◆ Capsule() [3/3]

template<typename Precision >
Capsule ( const Precision  _length,
const Precision  _radius,
const Material _mat 
)

Construct a capsule with a length, radius, and material.

Parameters
[in]_lengthLength of the capsule.
[in]_radiusRadius of the capsule.
[in]_matMaterial property for the capsule.

Member Function Documentation

◆ DensityFromMass()

template<typename Precision >
Precision DensityFromMass ( const Precision  _mass) const

Compute the capsule's density given a mass value. The capsule is assumed to be solid with uniform density. This function requires the capsule's radius and length to be set to values greater than zero. The Material of the capsule is ignored.

Parameters
[in]_massMass of the capsule, in kg. This value should be greater than zero.
Returns
Density of the capsule in kg/m^3. A NaN is returned if radius, length or _mass is <= 0.

◆ Length()

template<typename Precision >
Precision Length ( ) const

Get the length in meters.

Returns
The length of the capsule in meters.

◆ MassMatrix()

template<typename Precision >
std::optional< MassMatrix3< Precision > > MassMatrix ( ) const

Get the mass matrix for this capsule. This function is only meaningful if the capsule's radius, length, and material have been set.

Returns
The computed mass matrix if parameters are valid (radius > 0), (length > 0), and (density > 0). Otherwise std::nullopt is returned.

◆ Mat()

template<typename Precision >
const Material & Mat ( ) const

Get the material associated with this capsule.

Returns
The material assigned to this capsule

◆ operator==()

template<typename Precision >
bool operator== ( const Capsule< Precision > &  _capsule) const

Check if this capsule is equal to the provided capsule. Radius, length, and material properties will be checked.

◆ Radius()

template<typename Precision >
Precision Radius ( ) const

Get the radius in meters.

Returns
The radius of the capsule in meters.

◆ SetDensityFromMass()

template<typename Precision >
bool SetDensityFromMass ( const Precision  _mass)

Set the density of this capsule based on a mass value. Density is computed using Precision DensityFromMass(const Precision _mass) const. The capsule is assumed to be solid with uniform density. This function requires the capsule's radius and length to be set to values greater than zero. The existing Material density value is overwritten only if the return value from this true.

Parameters
[in]_massMass of the capsule, in kg. This value should be greater than zero.
Returns
True if the density was set. False is returned if the capsule's radius, length, or the _mass value are <= 0.
See also
Precision DensityFromMass(const Precision _mass) const

◆ SetLength()

template<typename Precision >
void SetLength ( const Precision  _length)

Set the length in meters.

Parameters
[in]_lengthThe length of the capsule in meters.

◆ SetMat()

template<typename Precision >
void SetMat ( const Material _mat)

Set the material associated with this capsule.

Parameters
[in]_matThe material assigned to this capsule

◆ SetRadius()

template<typename Precision >
void SetRadius ( const Precision  _radius)

Set the radius in meters.

Parameters
[in]_radiusThe radius of the capsule in meters.

◆ Volume()

template<typename Precision >
Precision Volume ( ) const

Get the volume of the capsule in m^3.

Returns
Volume of the capsule in m^3.

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