# Ignition Math

## API Reference

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

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

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

Precision Volume () const
Get the volume of the box in m^3. 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.

## ◆ 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] _length Length of the box in meters. [in] _width Width of the box in meters. [in] _height Height 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] _length Length of the box in meters. [in] _width Width of the box in meters. [in] _height Height of the box. [in] _mat Material property for the box.

## ◆ Box() [4/5]

 Box ( const Vector3< Precision > & _size )
explicit

Construct a box with specified dimensions, in vector form.

Parameters
 [in] _size Size 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] _size Size 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] _mat Material property for the box.

## ◆ ~Box()

 virtual ~Box ( )
virtualdefault

Destructor.

## ◆ 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] _mass Mass 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.

## ◆ 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] _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 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] _b Box to test.
Returns
True if not equal.

## ◆ operator==()

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

Equality test operator.

Parameters
 [in] _b Box 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] _mass Mass 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.
double DensityFromMass(const double _mass) const

## ◆ SetMaterial()

 void SetMaterial ( const Material & _mat )

Set the material associated with this box.

Parameters
 [in] _mat The material assigned to this box.

## ◆ SetSize() [1/2]

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

Set the size of the box.

Parameters
 [in] _size Size 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] _length Length of the box in meters. [in] _width Width of the box in meters. [in] _height Height of the box in meters.

## ◆ Size()

 math::Vector3 Size ( ) const

Get the size of the box.

Returns
Size of the box in meters.

## ◆ Volume()

 Precision Volume ( ) const

Get the volume of the box in m^3.

Returns
Volume of the box in m^3.

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