Mathematical representation of a box and related functions. More...
#include <ignition/math/Box.hh>
Public Member Functions | |
Box () | |
Default constructor. | |
Box (const Box &_b) | |
Copy Constructor. | |
Box (const Vector3d &_vec1, const Vector3d &_vec2) | |
Constructor. | |
Box (double _vec1X, double _vec1Y, double _vec1Z, double _vec2X, double _vec2Y, double _vec2Z) | |
Constructor. | |
virtual | ~Box () |
Destructor. | |
math::Vector3d | Center () const |
Get the box center. | |
bool | Contains (const Vector3d &_p) const |
Check if a point lies inside the box. | |
std::tuple< bool, double, Vector3d > | Intersect (const Line3d &_line) const |
Check if a line intersects the box. | |
std::tuple< bool, double, Vector3d > | Intersect (const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const |
Check if a ray (origin, direction) intersects the box. | |
bool | IntersectCheck (const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const |
Check if a ray (origin, direction) intersects the box. | |
std::tuple< bool, double > | IntersectDist (const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const |
Check if a ray (origin, direction) intersects the box. | |
bool | Intersects (const Box &_box) const |
Test box intersection. | |
Vector3d & | Max () |
Get a mutable version of the maximum corner. | |
const Vector3d & | Max () const |
Get the maximum corner. | |
void | Merge (const Box &_box) |
Merge a box with this box. | |
Vector3d & | Min () |
Get a mutable version of the minimum corner. | |
const Vector3d & | Min () const |
Get the minimum corner. | |
bool | operator!= (const Box &_b) const |
Inequality test operator. | |
Box | operator+ (const Box &_b) const |
Addition operator. | |
const Box & | operator+= (const Box &_b) |
Addition set operator. | |
Box | operator- (const Vector3d &_v) |
Subtract a vector from the min and max values. | |
Box & | operator= (const Box &_b) |
Assignment operator. | |
bool | operator== (const Box &_b) const |
Equality test operator. | |
math::Vector3d | Size () const |
Get the size of the box. | |
double | XLength () const |
Get the length along the x dimension. | |
double | YLength () const |
Get the length along the y dimension. | |
double | ZLength () const |
Get the length along the z dimension. | |
Mathematical representation of a box and related functions.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Box | ( | ) |
Default constructor.
This constructor will set the box's minimum and maximum corners to the highest (max) and lowest floating point values available to indicate that it is uninitialized. The default box does not intersect any other boxes or contain any points since it has no extent. Its center is the origin and its side lengths are 0.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Box | ( | const Vector3d & | _vec1, |
const Vector3d & | _vec2 ) |
Constructor.
This constructor will compute the box's minimum and maximum corners based on the two arguments.
[in] | _vec1 | One corner of the box |
[in] | _vec2 | Another corner of the box |
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Box | ( | double | _vec1X, |
double | _vec1Y, | ||
double | _vec1Z, | ||
double | _vec2X, | ||
double | _vec2Y, | ||
double | _vec2Z ) |
Constructor.
This constructor will compute the box's minimum and maximum corners based on the arguments.
[in] | _vec1X | One corner's X position |
[in] | _vec1Y | One corner's Y position |
[in] | _vec1Z | One corner's Z position |
[in] | _vec2X | Other corner's X position |
[in] | _vec2Y | Other corner's Y position |
[in] | _vec2Z | Other corner's Z position |
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Box | ( | const Box & | _b | ) |
Copy Constructor.
[in] | _b | Box to copy |
|
virtual |
Destructor.
math::Vector3d ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Center | ( | ) | const |
Get the box center.
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Plane< T >::Side().
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Contains | ( | const Vector3d & | _p | ) | const |
Check if a point lies inside the box.
[in] | _p | Point to check. |
std::tuple< bool, double, Vector3d > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Intersect | ( | const Line3d & | _line | ) | const |
Check if a line intersects the box.
[in] | _line | The line to check against this box. |
std::tuple< bool, double, Vector3d > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Intersect | ( | const Vector3d & | _origin, |
const Vector3d & | _dir, | ||
const double | _min, | ||
const double | _max ) const |
Check if a ray (origin, direction) intersects the box.
[in] | _origin | Origin of the ray. |
[in] | _dir | Direction of the ray. This ray will be normalized. |
[in] | _min | Minimum allowed distance. |
[in] | _max | Maximum allowed distance. |
The double is the distance from the ray's start to the closest intersection point on the box, minus the _min distance. For example, if _min == 0.5 and the intersection happens at a distance of 2.0 from _origin then returned distance is 1.5. The double value is zero when the boolean value is false. The
Vector3d is the intersection point on the box. The Vector3d value is zero if the boolean value is false.
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::IntersectCheck | ( | const Vector3d & | _origin, |
const Vector3d & | _dir, | ||
const double | _min, | ||
const double | _max ) const |
Check if a ray (origin, direction) intersects the box.
[in] | _origin | Origin of the ray. |
[in] | _dir | Direction of the ray. This ray will be normalized. |
[in] | _min | Minimum allowed distance. |
[in] | _max | Maximum allowed distance. |
std::tuple< bool, double > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::IntersectDist | ( | const Vector3d & | _origin, |
const Vector3d & | _dir, | ||
const double | _min, | ||
const double | _max ) const |
Check if a ray (origin, direction) intersects the box.
[in] | _origin | Origin of the ray. |
[in] | _dir | Direction of the ray. This ray will be normalized. |
[in] | _min | Minimum allowed distance. |
[in] | _max | Maximum allowed distance. |
The double is the distance from the ray's start to the closest intersection point on the box, minus the _min distance. For example, if _min == 0.5 and the intersection happens at a distance of 2.0 from _origin then returned distance is 1.5.
The double value is zero when the boolean value is false.
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Intersects | ( | const Box & | _box | ) | const |
Test box intersection.
This test will only work if both box's minimum corner is less than or equal to their maximum corner.
[in] | _box | Box to check for intersection with this box. |
Vector3d & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Max | ( | ) |
Get a mutable version of the maximum corner.
const Vector3d & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Max | ( | ) | const |
Get the maximum corner.
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Merge | ( | const Box & | _box | ) |
Merge a box with this box.
[in] | _box | Box to add to this box |
Vector3d & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Min | ( | ) |
Get a mutable version of the minimum corner.
const Vector3d & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Min | ( | ) | const |
Get the minimum corner.
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::operator!= | ( | const Box & | _b | ) | const |
Subtract a vector from the min and max values.
_v | The vector to use during subtraction |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::operator== | ( | const Box & | _b | ) | const |
math::Vector3d ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::Size | ( | ) | const |
Get the size of the box.
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Plane< T >::Side().
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::XLength | ( | ) | const |
Get the length along the x dimension.
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::YLength | ( | ) | const |
Get the length along the y dimension.
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Box::ZLength | ( | ) | const |
Get the length along the z dimension.