Gazebo Math

API Reference

8.0.0
Cylinder< Precision > Class Template Reference

A representation of a cylinder. More...

#include <gz/math/Cylinder.hh>

Public Member Functions

 Cylinder ()=default
 Default constructor. The default radius and length are both zero. The default rotational offset is Quaternion<Precision>::Identity.
 
 Cylinder (const Precision _length, const Precision _radius, const Material &_mat, const Quaternion< Precision > &_rotOffset=Quaternion< Precision >::Identity)
 Construct a cylinder with a length, radius, material and optionally a rotational offset.
 
 Cylinder (const Precision _length, const Precision _radius, const Quaternion< Precision > &_rotOffset=Quaternion< Precision >::Identity)
 Construct a cylinder with a length, radius, and optionally a rotational offset.
 
Precision DensityFromMass (const Precision _mass) const
 Compute the cylinder's density given a mass value. The cylinder is assumed to be solid with uniform density. This function requires the cylinder's radius and length to be set to values greater than zero. The Material of the cylinder is ignored.
 
Precision Length () const
 Get the length in meters.
 
std::optional< MassMatrix3< Precision > > MassMatrix () const
 Get the mass matrix for this cylinder. This function is only meaningful if the cylinder's radius, length, and material have been set. Optionally, set the rotational offset.
 
bool MassMatrix (MassMatrix3d &_massMat) const
 Get the mass matrix for this cylinder. This function is only meaningful if the cylinder's radius, length, and material have been set. Optionally, set the rotational offset.
 
const MaterialMat () const
 Get the material associated with this cylinder.
 
bool operator== (const Cylinder &_cylinder) const
 Check if this cylinder is equal to the provided cylinder. Radius, length, and material properties will be checked.
 
Precision Radius () const
 Get the radius in meters.
 
Quaternion< PrecisionRotationalOffset () const
 Get the rotational offset. By default, a cylinder's length is aligned with the Z axis. The rotational offset encodes a rotation from the z axis.
 
bool SetDensityFromMass (const Precision _mass)
 Set the density of this cylinder based on a mass value. Density is computed using Precision DensityFromMass(const Precision _mass) const. The cylinder is assumed to be solid with uniform density. This function requires the cylinder'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 cylinder.
 
void SetRadius (const Precision _radius)
 Set the radius in meters.
 
void SetRotationalOffset (const Quaternion< Precision > &_rotOffset)
 Set the rotation offset. See Quaternion<Precision> RotationalOffset() for details on the rotational offset.
 
Precision Volume () const
 Get the volume of the cylinder in m^3.
 

Detailed Description

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

A representation of a cylinder.

The cylinder class supports defining a cylinder with a radius, length, rotational offset, and material properties. Radius and length are in meters. See Material for more on material properties. By default, a cylinder's length is aligned with the Z axis. The rotational offset encodes a rotation from the z axis.

Constructor & Destructor Documentation

◆ Cylinder() [1/3]

template<typename Precision >
Cylinder ( )
default

Default constructor. The default radius and length are both zero. The default rotational offset is Quaternion<Precision>::Identity.

◆ Cylinder() [2/3]

template<typename Precision >
Cylinder ( const Precision  _length,
const Precision  _radius,
const Quaternion< Precision > &  _rotOffset = QuaternionPrecision >::Identity 
)

Construct a cylinder with a length, radius, and optionally a rotational offset.

Parameters
[in]_lengthLength of the cylinder.
[in]_radiusRadius of the cylinder.
[in]_rotOffsetRotational offset of the cylinder.

◆ Cylinder() [3/3]

template<typename Precision >
Cylinder ( const Precision  _length,
const Precision  _radius,
const Material _mat,
const Quaternion< Precision > &  _rotOffset = QuaternionPrecision >::Identity 
)

Construct a cylinder with a length, radius, material and optionally a rotational offset.

Parameters
[in]_lengthLength of the cylinder.
[in]_radiusRadius of the cylinder.
[in]_matMaterial property for the cylinder.
[in]_rotOffsetRotational offset of the cylinder.

Member Function Documentation

◆ DensityFromMass()

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

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

Parameters
[in]_massMass of the cylinder, in kg. This value should be greater than zero.
Returns
Density of the cylinder in kg/m^3. A negative value 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 cylinder in meters.

◆ MassMatrix() [1/2]

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

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

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

◆ MassMatrix() [2/2]

template<typename Precision >
bool MassMatrix ( MassMatrix3d _massMat) const

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

Parameters
[out]_massMatThe computed mass matrix will be stored here.
Returns
False if computation of the mass matrix failed, which could be due to an invalid radius (<=0), length (<=0), or density (<=0).

◆ Mat()

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

Get the material associated with this cylinder.

Returns
The material assigned to this cylinder

◆ operator==()

template<typename Precision >
bool operator== ( const Cylinder< Precision > &  _cylinder) const

Check if this cylinder is equal to the provided cylinder. 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 cylinder in meters.

◆ RotationalOffset()

template<typename Precision >
Quaternion< Precision > RotationalOffset ( ) const

Get the rotational offset. By default, a cylinder's length is aligned with the Z axis. The rotational offset encodes a rotation from the z axis.

Returns
The cylinder's rotational offset.
See also
void SetRotationalOffset(const Quaternion<Precision> &_rot)

◆ SetDensityFromMass()

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

Set the density of this cylinder based on a mass value. Density is computed using Precision DensityFromMass(const Precision _mass) const. The cylinder is assumed to be solid with uniform density. This function requires the cylinder'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 cylinder, in kg. This value should be greater than zero.
Returns
True if the density was set. False is returned if the cylinder'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 cylinder in meters.

◆ SetMat()

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

Set the material associated with this cylinder.

Parameters
[in]_matThe material assigned to this cylinder

◆ SetRadius()

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

Set the radius in meters.

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

◆ SetRotationalOffset()

template<typename Precision >
void SetRotationalOffset ( const Quaternion< Precision > &  _rotOffset)

Set the rotation offset. See Quaternion<Precision> RotationalOffset() for details on the rotational offset.

See also
Quaternion<Precision> RotationalOffset() const

◆ Volume()

template<typename Precision >
Precision Volume ( ) const

Get the volume of the cylinder in m^3.

Returns
Volume of the cylinder in m^3.

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