A representation of a sphere. More...
#include <gz/math/Sphere.hh>
Public Member Functions | |
Sphere ()=default | |
Default constructor. The default radius is zero. More... | |
Sphere (const Precision _radius) | |
Construct a sphere with a radius. More... | |
Sphere (const Precision _radius, const Material &_mat) | |
Construct a sphere with a radius, material. More... | |
std::optional< Vector3< Precision > > | CenterOfVolumeBelow (const Plane< Precision > &_plane) const |
Center of volume below the plane. This is useful for example when calculating where buoyancy should be applied. More... | |
Precision | DensityFromMass (const Precision _mass) const |
Compute the sphere's density given a mass value. The sphere is assumed to be solid with uniform density. This function requires the sphere's radius to be set to a value greater than zero. The Material of the sphere is ignored. More... | |
std::optional< MassMatrix3< Precision > > | MassMatrix () const |
Get the mass matrix for this sphere. This function is only meaningful if the sphere's radius and material have been set. More... | |
bool | MassMatrix (MassMatrix3d &_massMat) const |
Get the mass matrix for this sphere. This function is only meaningful if the sphere's radius and material have been set. More... | |
const Material & | Material () const |
Get the material associated with this sphere. More... | |
bool | operator!= (const Sphere &_sphere) const |
Check if this sphere is not equal to the provided sphere. Radius and material properties will be checked. More... | |
bool | operator== (const Sphere &_sphere) const |
Check if this sphere is equal to the provided sphere. Radius 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 sphere based on a mass value. Density is computed using Precision DensityFromMass(const Precision _mass) const. The sphere is assumed to be solid with uniform density. This function requires the sphere's radius to be set to a value greater than zero. The existing Material density value is overwritten only if the return value from this true. More... | |
void | SetMaterial (const Material &_mat) |
Set the material associated with this sphere. More... | |
void | SetRadius (const Precision _radius) |
Set the radius in meters. More... | |
Precision | Volume () const |
Get the volume of the sphere in m^3. More... | |
Precision | VolumeBelow (const Plane< Precision > &_plane) const |
Get the volume of sphere below a given plane in m^3. It is assumed that the center of the sphere is on the origin. More... | |
Detailed Description
template<typename Precision>
class gz::math::Sphere< Precision >
A representation of a sphere.
The sphere class supports defining a sphere with a radius and material properties. Radius is in meters. See Material for more on material properties.
Constructor & Destructor Documentation
◆ Sphere() [1/3]
|
default |
Default constructor. The default radius is zero.
◆ Sphere() [2/3]
|
explicit |
Construct a sphere with a radius.
- Parameters
-
[in] _radius Radius of the sphere.
◆ Sphere() [3/3]
Construct a sphere with a radius, material.
- Parameters
-
[in] _radius Radius of the sphere. [in] _mat Material property for the sphere.
Member Function Documentation
◆ CenterOfVolumeBelow()
Center of volume below the plane. This is useful for example when calculating where buoyancy should be applied.
- Parameters
-
[in] _plane The plane which slices this sphere, expressed in the sphere's reference frame.
- Returns
- The center of volume if there is anything under the plane, otherwise return a std::nullopt. Expressed in the sphere's reference frame.
◆ DensityFromMass()
Precision DensityFromMass | ( | const Precision | _mass | ) | const |
Compute the sphere's density given a mass value. The sphere is assumed to be solid with uniform density. This function requires the sphere's radius to be set to a value greater than zero. The Material of the sphere is ignored.
- Parameters
-
[in] _mass Mass of the sphere, in kg. This value should be greater than zero.
- Returns
- Density of the sphere in kg/m^3. A negative value is returned if radius or _mass is <= 0.
◆ MassMatrix() [1/2]
std::optional< MassMatrix3<Precision> > MassMatrix | ( | ) | const |
Get the mass matrix for this sphere. This function is only meaningful if the sphere's radius and material have been set.
- Returns
- The computed mass matrix if parameters are valid (radius > 0) and (density > 0). Otherwise std::nullopt is returned.
◆ MassMatrix() [2/2]
bool MassMatrix | ( | MassMatrix3d & | _massMat | ) | const |
Get the mass matrix for this sphere. This function is only meaningful if the sphere's radius and material have been set.
- 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) or density (<=0).
◆ Material()
Get the material associated with this sphere.
- Returns
- The material assigned to this sphere
◆ operator!=()
bool operator!= | ( | const Sphere< Precision > & | _sphere | ) | const |
Check if this sphere is not equal to the provided sphere. Radius and material properties will be checked.
◆ operator==()
bool operator== | ( | const Sphere< Precision > & | _sphere | ) | const |
Check if this sphere is equal to the provided sphere. Radius and material properties will be checked.
◆ Radius()
Precision Radius | ( | ) | const |
Get the radius in meters.
- Returns
- The radius of the sphere in meters.
◆ SetDensityFromMass()
bool SetDensityFromMass | ( | const Precision | _mass | ) |
Set the density of this sphere based on a mass value. Density is computed using Precision DensityFromMass(const Precision _mass) const. The sphere is assumed to be solid with uniform density. This function requires the sphere's radius to be set to a value greater than zero. The existing Material density value is overwritten only if the return value from this true.
- Parameters
-
[in] _mass Mass of the sphere, in kg. This value should be greater than zero.
- Returns
- True if the density was set. False is returned if the sphere's radius or the _mass value are <= 0.
- See also
- Precision DensityFromMass(const Precision _mass) const
◆ SetMaterial()
void SetMaterial | ( | const Material & | _mat | ) |
Set the material associated with this sphere.
- Parameters
-
[in] _mat The material assigned to this sphere
◆ SetRadius()
void SetRadius | ( | const Precision | _radius | ) |
Set the radius in meters.
- Parameters
-
[in] _radius The radius of the sphere in meters.
◆ Volume()
Precision Volume | ( | ) | const |
Get the volume of the sphere in m^3.
- Returns
- Volume of the sphere in m^3.
◆ VolumeBelow()
Precision VolumeBelow | ( | const Plane< Precision > & | _plane | ) | const |
Get the volume of sphere below a given plane in m^3. It is assumed that the center of the sphere is on the origin.
- Parameters
-
[in] _plane The plane which slices this sphere, expressed in the sphere's reference frame.
- Returns
- Volume below the sphere in m^3.
The documentation for this class was generated from the following file: