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 Material & | Mat () 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
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
-
Precision Scalar numeric type.
Constructor & Destructor Documentation
◆ Capsule() [1/3]
Default constructor. The default radius and length are both zero.
◆ Capsule() [2/3]
Construct a capsule with a length and radius.
- Parameters
-
[in] _length Length of the capsule. [in] _radius Radius of the capsule.
◆ Capsule() [3/3]
Construct a capsule with a length, radius, and material.
- Parameters
-
[in] _length Length of the capsule. [in] _radius Radius of the capsule. [in] _mat Material property for the capsule.
Member Function Documentation
◆ DensityFromMass()
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] _mass Mass 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()
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()
Get the material associated with this capsule.
- Returns
- The material assigned to this capsule
◆ operator==()
Check if this capsule is equal to the provided capsule. Radius, length, and material properties will be checked.
◆ Radius()
Get the radius in meters.
- Returns
- The radius of the capsule in meters.
◆ SetDensityFromMass()
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] _mass Mass 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()
Set the length in meters.
- Parameters
-
[in] _length The length of the capsule in meters.
◆ SetMat()
Set the material associated with this capsule.
- Parameters
-
[in] _mat The material assigned to this capsule
◆ SetRadius()
Set the radius in meters.
- Parameters
-
[in] _radius The radius of the capsule in meters.
◆ Volume()
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: