# Ignition Math

## API Reference

6.10.0
Cylinder< Precision > Class Template Reference

A representation of a cylinder. More...

#include <ignition/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. More...

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. More...

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. More...

~Cylinder ()=default
Destructor. More...

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. More...

Precision Length () const
Get the length in meters. More...

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. More...

const MaterialMat () const
Get the material associated with this cylinder. More...

bool operator== (const Cylinder &_cylinder) const
Check if this cylinder is equal to the provided cylinder. Radius, length, and material properties will be checked. More...

Get the radius in meters. More...

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. More...

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. More...

void SetLength (const Precision _length)
Set the length in meters. More...

void SetMat (const Material &_mat)
Set the material associated with this cylinder. More...

Set the radius in meters. More...

void SetRotationalOffset (const Quaternion< Precision > &_rotOffset)
Set the rotation offset. See Quaternion<Precision> RotationalOffset() for details on the rotational offset. More...

Precision Volume () const
Get the volume of the cylinder in m^3. More...

## Detailed Description

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

## ◆ Cylinder() [1/3]

 Cylinder ( )
default

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

## ◆ Cylinder() [2/3]

 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.

Parameters
 [in] _length Length of the cylinder. [in] _radius Radius of the cylinder. [in] _rotOffset Rotational offset of the cylinder.

## ◆ Cylinder() [3/3]

 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.

Parameters
 [in] _length Length of the cylinder. [in] _radius Radius of the cylinder. [in] _mat Material property for the cylinder. [in] _rotOffset Rotational offset of the cylinder.

## ◆ ~Cylinder()

 ~Cylinder ( )
default

Destructor.

## ◆ DensityFromMass()

 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] _mass Mass 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()

 Precision Length ( ) const

Get the length in meters.

Returns
The length of the cylinder in meters.

## ◆ MassMatrix()

 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] _massMat The 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()

 const Material& Mat ( ) const

Get the material associated with this cylinder.

Returns
The material assigned to this cylinder

## ◆ operator==()

 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.

Returns
The radius of the cylinder in meters.

## ◆ RotationalOffset()

 Quaternion 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.
void SetRotationalOffset(const Quaternion<Precision> &_rot)

## ◆ SetDensityFromMass()

 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] _mass Mass 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.
Precision DensityFromMass(const Precision _mass) const

## ◆ SetLength()

 void SetLength ( const Precision _length )

Set the length in meters.

Parameters
 [in] _length The length of the cylinder in meters.

## ◆ SetMat()

 void SetMat ( const Material & _mat )

Set the material associated with this cylinder.

Parameters
 [in] _mat The material assigned to this cylinder

Parameters

## ◆ SetRotationalOffset()

 void SetRotationalOffset ( const Quaternion< Precision > & _rotOffset )

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