Ignition Math

API Reference

6.10.0
Box< Precision > Class Template Reference

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

#include <ignition/math/Box.hh>

Public Member Functions

 Box ()=default
 Default constructor. More...
 
 Box (const Precision _length, const Precision _width, const Precision _height)
 Construct a box with specified dimensions. More...
 
 Box (const Precision _length, const Precision _width, const Precision _height, const Material &_mat)
 Construct a box with specified dimensions and a material. More...
 
 Box (const Vector3< Precision > &_size)
 Construct a box with specified dimensions, in vector form. More...
 
 Box (const Vector3< Precision > &_size, const Material &_mat)
 Construct a box with specified dimensions, in vector form and a material. More...
 
virtual ~Box ()=default
 Destructor. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const MaterialMaterial () const
 Get the material associated with this box. More...
 
bool operator!= (const Box< Precision > &_b) const
 Inequality test operator. More...
 
bool operator== (const Box< Precision > &_b) const
 Equality test operator. More...
 
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. More...
 
void SetMaterial (const Material &_mat)
 Set the material associated with this box. More...
 
void SetSize (const math::Vector3< Precision > &_size)
 Set the size of the box. More...
 
void SetSize (const Precision _length, const Precision _width, const Precision _height)
 Set the size of the box. More...
 
math::Vector3< Precision > Size () const
 Get the size of the box. More...
 
IntersectionPoints< Precision > VerticesBelow (const Plane< Precision > &_plane) const
 All the vertices which are on or below the plane. More...
 
Precision Volume () const
 Get the volume of the box in m^3. More...
 
Precision VolumeBelow (const Plane< Precision > &_plane) const
 Get the volume of the box below a plane. More...
 

Detailed Description

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

Box ( )
default

Default constructor.

◆ Box() [2/5]

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]

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]

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]

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.

◆ ~Box()

virtual ~Box ( )
virtualdefault

Destructor.

Member Function Documentation

◆ CenterOfVolumeBelow()

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()

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()

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()

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()

const Material& Material ( ) const

Get the material associated with this box.

Returns
The material assigned to this box.

◆ operator!=()

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

Inequality test operator.

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

◆ operator==()

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

Equality test operator.

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

◆ SetDensityFromMass()

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()

void SetMaterial ( const Material _mat)

Set the material associated with this box.

Parameters
[in]_matThe material assigned to this box.

◆ SetSize() [1/2]

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]

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()

math::Vector3<Precision> Size ( ) const

Get the size of the box.

Returns
Size of the box in meters.

◆ VerticesBelow()

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()

Precision Volume ( ) const

Get the volume of the box in m^3.

Returns
Volume of the box in m^3.

◆ VolumeBelow()

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: