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< Precision > | Intersections (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 Material & | Material () 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< Precision > | Size () const |
Get the size of the box. | |
IntersectionPoints< Precision > | VerticesBelow (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
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() [2/5]
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]
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]
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.
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] _plane The plane which cuts the box, expressed in the box's frame.
- Returns
- Center of volume, in box's frame.
◆ DensityFromMass()
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.
◆ 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] _plane The 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]
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]
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()
Get the material associated with this box.
- Returns
- The material assigned to this box.
◆ operator!=()
◆ operator==()
◆ SetDensityFromMass()
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.
- See also
- double DensityFromMass(const double _mass) const
◆ SetMaterial()
Set the material associated with this box.
- Parameters
-
[in] _mat The material assigned to this box.
◆ SetSize() [1/2]
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]
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< 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] _plane The 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()
Get the volume of the box in m^3.
- Returns
- Volume of the box in m^3.
◆ VolumeBelow()
Get the volume of the box below a plane.
- Parameters
-
[in] _plane The 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: