Gazebo Math

API Reference

6.15.1
Capsule< Precision > Class Template Reference

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

#include <ignition/math/Capsule.hh>

Public Member Functions

 Capsule ()=default
 Default constructor. The default radius and length are both zero. More...
 
 Capsule (const Precision _length, const Precision _radius)
 Construct a capsule with a length and radius. More...
 
 Capsule (const Precision _length, const Precision _radius, const Material &_mat)
 Construct a capsule with a length, radius, and material. More...
 
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. More...
 
Precision Length () const
 Get the length in meters. More...
 
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. More...
 
const MaterialMat () const
 Get the material associated with this capsule. More...
 
bool operator== (const Capsule &_capsule) const
 Check if this capsule is equal to the provided capsule. Radius, length, and material properties will be checked. More...
 
Precision Radius () const
 Get the radius in meters. More...
 
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. More...
 
void SetLength (const Precision _length)
 Set the length in meters. More...
 
void SetMat (const Material &_mat)
 Set the material associated with this capsule. More...
 
void SetRadius (const Precision _radius)
 Set the radius in meters. More...
 
Precision Volume () const
 Get the volume of the capsule in m^3. More...
 

Detailed Description

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

Capsule ( )
default

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

◆ Capsule() [2/3]

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]

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()

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()

Precision Length ( ) const

Get the length in meters.

Returns
The length of the capsule in meters.

◆ MassMatrix()

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()

const Material& Mat ( ) const

Get the material associated with this capsule.

Returns
The material assigned to this capsule

◆ operator==()

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()

Precision Radius ( ) const

Get the radius in meters.

Returns
The radius of the capsule in meters.

◆ SetDensityFromMass()

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()

void SetLength ( const Precision  _length)

Set the length in meters.

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

◆ SetMat()

void SetMat ( const Material _mat)

Set the material associated with this capsule.

Parameters
[in]_matThe material assigned to this capsule

◆ SetRadius()

void SetRadius ( const Precision  _radius)

Set the radius in meters.

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

◆ Volume()

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: