Gazebo Math

API Reference

8.1.0
Box< Precision > Class Template Reference

A representation of a box. All units are in meters. More...

#include <gz/math/Box.hh>

Public Member Functions

 Box ()=default
 Default constructor.
 
 Box (const Precision _length, const Precision _width, const Precision _height)
 Construct a box with specified dimensions.
 
 Box (const Precision _length, const Precision _width, const Precision _height, const Material &_mat)
 Construct a box with specified dimensions and a material.
 
 Box (const Vector3< Precision > &_size)
 Construct a box with specified dimensions, in vector form.
 
 Box (const Vector3< Precision > &_size, const Material &_mat)
 Construct a box with specified dimensions, in vector form and a material.
 
std::optional< Vector3< Precision > > CenterOfVolumeBelow (const Plane< Precision > &_plane) const
 Center of volume below the plane. This is useful when calculating where buoyancy should be applied, for example.
 
Precision DensityFromMass (const Precision _mass) const
 Compute the box's density given a mass value. The box is assumed to be solid with uniform density. This function requires the box's size to be set to values greater than zero. The Material of the box is ignored.
 
IntersectionPoints< PrecisionIntersections (const Plane< Precision > &_plane) const
 Get intersection between a plane and the box's edges. Edges contained on the plane are ignored.
 
std::optional< MassMatrix3< Precision > > MassMatrix () const
 Get the mass matrix for this box. This function is only meaningful if the box's size and material have been set.
 
bool MassMatrix (MassMatrix3< Precision > &_massMat) const
 Get the mass matrix for this box. This function is only meaningful if the box's size and material have been set.
 
const MaterialMaterial () const
 Get the material associated with this box.
 
bool operator!= (const Box< Precision > &_b) const
 Inequality test operator.
 
bool operator== (const Box< Precision > &_b) const
 Equality test operator.
 
bool SetDensityFromMass (const Precision _mass)
 Set the density of this box based on a mass value. Density is computed using double DensityFromMass(const double _mass) const. The box is assumed to be solid with uniform density. This function requires the box's size to be set to values greater than zero. The existing Material density value is overwritten only if the return value from this true.
 
void SetMaterial (const Material &_mat)
 Set the material associated with this box.
 
void SetSize (const math::Vector3< Precision > &_size)
 Set the size of the box.
 
void SetSize (const Precision _length, const Precision _width, const Precision _height)
 Set the size of the box.
 
math::Vector3< PrecisionSize () const
 Get the size of the box.
 
IntersectionPoints< PrecisionVerticesBelow (const Plane< Precision > &_plane) const
 All the vertices which are on or below the plane.
 
Precision Volume () const
 Get the volume of the box in m^3.
 
Precision VolumeBelow (const Plane< Precision > &_plane) const
 Get the volume of the box below a plane.
 

Detailed Description

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

A representation of a box. All units are in meters.

The box class supports defining a size and material properties. See Material for more on material properties.

By default, a box's size (length, width, and height) is zero.

See AxisAlignedBox for an axis aligned box implementation.

Constructor & Destructor Documentation

◆ Box() [1/5]

template<typename Precision >
Box ( )
default

Default constructor.

◆ Box() [2/5]

template<typename Precision >
Box ( const Precision  _length,
const Precision  _width,
const Precision  _height 
)

Construct a box with specified dimensions.

Parameters
[in]_lengthLength of the box in meters.
[in]_widthWidth of the box in meters.
[in]_heightHeight of the box in meters.

◆ Box() [3/5]

template<typename Precision >
Box ( const Precision  _length,
const Precision  _width,
const Precision  _height,
const Material _mat 
)

Construct a box with specified dimensions and a material.

Parameters
[in]_lengthLength of the box in meters.
[in]_widthWidth of the box in meters.
[in]_heightHeight of the box.
[in]_matMaterial property for the box.

◆ Box() [4/5]

template<typename Precision >
Box ( const Vector3< Precision > &  _size)
explicit

Construct a box with specified dimensions, in vector form.

Parameters
[in]_sizeSize of the box. The vector _size has the following mapping:
  • _size[0] == length in meters
  • _size[1] == width in meters
  • _size[2] == height in meters

◆ Box() [5/5]

template<typename Precision >
Box ( const Vector3< Precision > &  _size,
const Material _mat 
)

Construct a box with specified dimensions, in vector form and a material.

Parameters
[in]_sizeSize of the box. The vector _size has the following mapping:
  • _size[0] == length in meters
  • _size[1] == width in meters
  • _size[2] == height in meters
    Parameters
    [in]_matMaterial property for the box.

Member Function Documentation

◆ CenterOfVolumeBelow()

template<typename Precision >
std::optional< Vector3< Precision > > CenterOfVolumeBelow ( const Plane< Precision > &  _plane) const

Center of volume below the plane. This is useful when calculating where buoyancy should be applied, for example.

Parameters
[in]_planeThe plane which cuts the box, expressed in the box's frame.
Returns
Center of volume, in box's frame.

◆ DensityFromMass()

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

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

Parameters
[in]_massMass of the box, in kg. This value should be greater than zero.
Returns
Density of the box in kg/m^3. A negative value is returned if the size or _mass is <= 0.

◆ Intersections()

template<typename Precision >
IntersectionPoints< Precision > Intersections ( const Plane< Precision > &  _plane) const

Get intersection between a plane and the box's edges. Edges contained on the plane are ignored.

Parameters
[in]_planeThe plane against which we are testing intersection.
Returns
A list of points along the edges of the box where the intersection occurs.

◆ MassMatrix() [1/2]

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

Get the mass matrix for this box. This function is only meaningful if the box's size 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.

◆ MassMatrix() [2/2]

template<typename Precision >
bool MassMatrix ( MassMatrix3< Precision > &  _massMat) const

Get the mass matrix for this box. This function is only meaningful if the box's size and material have been set.

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 size (<=0) or density (<=0).

◆ Material()

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

Get the material associated with this box.

Returns
The material assigned to this box.

◆ operator!=()

template<typename Precision >
bool operator!= ( const Box< Precision > &  _b) const

Inequality test operator.

Parameters
[in]_bBox to test.
Returns
True if not equal.

◆ operator==()

template<typename Precision >
bool operator== ( const Box< Precision > &  _b) const

Equality test operator.

Parameters
[in]_bBox to test.
Returns
True if equal.

◆ SetDensityFromMass()

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

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

◆ SetMaterial()

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

Set the material associated with this box.

Parameters
[in]_matThe material assigned to this box.

◆ SetSize() [1/2]

template<typename Precision >
void SetSize ( const math::Vector3< Precision > &  _size)

Set the size of the box.

Parameters
[in]_sizeSize of the box. The vector _size has the following mapping:
  • _size[0] == lengt in metersh
  • _size[1] == widt in metersh
  • _size[2] == heigh in meterst

◆ SetSize() [2/2]

template<typename Precision >
void SetSize ( const Precision  _length,
const Precision  _width,
const Precision  _height 
)

Set the size of the box.

Parameters
[in]_lengthLength of the box in meters.
[in]_widthWidth of the box in meters.
[in]_heightHeight of the box in meters.

◆ Size()

template<typename Precision >
math::Vector3< Precision > Size ( ) const

Get the size of the box.

Returns
Size of the box in meters.

◆ VerticesBelow()

template<typename Precision >
IntersectionPoints< Precision > VerticesBelow ( const Plane< Precision > &  _plane) const

All the vertices which are on or below the plane.

Parameters
[in]_planeThe plane which cuts the box, expressed in the box's frame.
Returns
Box vertices which are below the plane, expressed in the box's frame.

◆ Volume()

template<typename Precision >
Precision Volume ( ) const

Get the volume of the box in m^3.

Returns
Volume of the box in m^3.

◆ VolumeBelow()

template<typename Precision >
Precision VolumeBelow ( const Plane< Precision > &  _plane) const

Get the volume of the box below a plane.

Parameters
[in]_planeThe plane which cuts the box, expressed in the box's frame.
Returns
Volume below the plane in m^3.

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