Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Public Types | Public Member Functions | List of all members
jau::math::geom::AABBox3f Class Reference

Axis Aligned Bounding Box. More...

#include <aabbox3f.hpp>

Collaboration diagram for jau::math::geom::AABBox3f:

Public Types

typedef jau::function< jau::math::Vec3f(const jau::math::Vec3f &)> transform_vec3f_func
 General purpose Vec3f transform function. More...
 

Public Member Functions

 AABBox3f () noexcept
 Create an Axis Aligned bounding box (aabbox3f) where the low and and high MAX float Values. More...
 
constexpr AABBox3f (AABBox3f &&o) noexcept=default
 
constexpr AABBox3f (const AABBox3f &o) noexcept=default
 
 AABBox3f (const Point3f &bl_, const Point3f &tr_) noexcept
 Create an aabbox3f with given bl (low) and tr (high) More...
 
float area2D () const noexcept
 Returns the assumed 2D area, i.e. More...
 
const Point3fcenter () const noexcept
 Returns computed center of this aabbox3f of low() and high(). More...
 
bool contains (const AABBox3f &o) const noexcept
 Returns whether this aabbox3f fully contains given aabbox3f. More...
 
bool contains (const float x, const float y) const noexcept
 Check if the 2D point is bounded/contained by this aabbox3f. More...
 
bool contains (const float x, const float y, const float z) const noexcept
 Check if the 3D point is bounded/contained by this aabbox3f. More...
 
bool contains (const Point2f &p) const noexcept
 Check if the 2D point is bounded/contained by this aabbox3f. More...
 
bool contains (const Point3f &p) const noexcept
 Check if the 3D point is bounded/contained by this aabbox3f. More...
 
float depth () const noexcept
 
bool getRayIntersection (Vec3f &result, const Ray3f &ray, const float epsilon, const bool assumeIntersection)
 Return intersection of a Ray with this bounding box, or false if none exist. More...
 
bool hasZeroArea2D () const noexcept
 Return true if get2DArea() is FloatUtil#isZero(float), considering epsilon. More...
 
bool hasZeroVolume () const noexcept
 Return true if getVolume() is FloatUtil#isZero(float), considering epsilon. More...
 
float height () const noexcept
 
const Point3fhigh () const noexcept
 Returns the maximum right-top-near (xyz) coordinate. More...
 
bool intersects (const AABBox3f &o) const noexcept
 Returns whether this aabbox3f intersects (partially contains) given aabbox3f. More...
 
bool intersects2DRegion (const float x, const float y, const float w, const float h) const noexcept
 Check if there is a common region between this AABBox and the passed 2D region irrespective of z range. More...
 
bool intersectsRay (const Ray3f ray) const noexcept
 Check if Ray intersects this bounding box. More...
 
const Point3flow () const noexcept
 Returns the minimum left-bottom-far (xyz) coordinate. More...
 
AABBox3foperator= (AABBox3f &&) noexcept=default
 
AABBox3foperator= (const AABBox3f &) noexcept=default
 
AABBox3freset () noexcept
 Reset this box to the inverse low/high, allowing the next resize(float, float, float) command to hit. More...
 
AABBox3fresize (const AABBox3f &newBox, transform_vec3f_func &transform) noexcept
 Resize the aabbox3f to encapsulate another AABox, which will be transformed on the fly first. More...
 
AABBox3fresize (const AABBox3f &o) noexcept
 Resize the aabbox3f to encapsulate another AABox. More...
 
AABBox3fresize (const float x, const float y, const float z) noexcept
 Resize the aabbox3f to encapsulate the passed xyz-coordinates. More...
 
AABBox3fresize (const float xyz[]) noexcept
 Resize the aabbox3f to encapsulate the passed xyz-coordinates. More...
 
AABBox3fresize (const Point3f &p) noexcept
 Resize the aabbox3f to encapsulate the passed xyz-coordinates. More...
 
AABBox3fresizeHeight (const float deltaBottom, const float deltaTop) noexcept
 Resize height of this aabbox3f with explicit bottom- and top delta values. More...
 
AABBox3fresizeWidth (const float deltaLeft, const float deltaRight) noexcept
 Resize width of this aabbox3f with explicit left- and right delta values. More...
 
AABBox3fsetSize (const float low[], const float high[]) noexcept
 Set size of the aabbox3f specifying the coordinates of the low and high. More...
 
AABBox3fsetSize (const float lx, const float ly, const float lz, const float hx, const float hy, const float hz) noexcept
 Set size of the aabbox3f specifying the coordinates of the low and high. More...
 
AABBox3fsetSize (const Vec3f &low, const Vec3f &high) noexcept
 Set size of the aabbox3f specifying the coordinates of the low and high. More...
 
float size () const noexcept
 Get the size of this aabbox3f where the size is represented by the length of the vector between low and high. More...
 
std::string toString () const noexcept
 
float volume () const noexcept
 Returns the volume, i.e. More...
 
float width () const noexcept
 

Detailed Description

Axis Aligned Bounding Box.

Defined by two 3D coordinates (low and high) The low being the the lower left corner of the box, and the high being the upper right corner of the box.

A few references for collision detection, intersections:

Definition at line 49 of file aabbox3f.hpp.

Member Typedef Documentation

◆ transform_vec3f_func

General purpose Vec3f transform function.

Definition at line 263 of file aabbox3f.hpp.

Constructor & Destructor Documentation

◆ AABBox3f() [1/4]

jau::math::geom::AABBox3f::AABBox3f ( )
inlinenoexcept

Create an Axis Aligned bounding box (aabbox3f) where the low and and high MAX float Values.

Definition at line 63 of file aabbox3f.hpp.

◆ AABBox3f() [2/4]

jau::math::geom::AABBox3f::AABBox3f ( const Point3f bl_,
const Point3f tr_ 
)
inlinenoexcept

Create an aabbox3f with given bl (low) and tr (high)

Definition at line 70 of file aabbox3f.hpp.

◆ AABBox3f() [3/4]

constexpr jau::math::geom::AABBox3f::AABBox3f ( const AABBox3f o)
constexprdefaultnoexcept

◆ AABBox3f() [4/4]

constexpr jau::math::geom::AABBox3f::AABBox3f ( AABBox3f &&  o)
constexprdefaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

AABBox3f & jau::math::geom::AABBox3f::operator= ( const AABBox3f )
defaultnoexcept

◆ operator=() [2/2]

AABBox3f & jau::math::geom::AABBox3f::operator= ( AABBox3f &&  )
defaultnoexcept

◆ reset()

AABBox3f & jau::math::geom::AABBox3f::reset ( )
inlinenoexcept

Reset this box to the inverse low/high, allowing the next resize(float, float, float) command to hit.

Returns
this aabbox3f for chaining

Definition at line 97 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ high()

const Point3f & jau::math::geom::AABBox3f::high ( ) const
inlinenoexcept

Returns the maximum right-top-near (xyz) coordinate.

Definition at line 105 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ low()

const Point3f & jau::math::geom::AABBox3f::low ( ) const
inlinenoexcept

Returns the minimum left-bottom-far (xyz) coordinate.

Definition at line 108 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ center()

const Point3f & jau::math::geom::AABBox3f::center ( ) const
inlinenoexcept

Returns computed center of this aabbox3f of low() and high().

Definition at line 111 of file aabbox3f.hpp.

◆ size()

float jau::math::geom::AABBox3f::size ( ) const
inlinenoexcept

Get the size of this aabbox3f where the size is represented by the length of the vector between low and high.

Returns
a float representing the size of the aabbox3f

Definition at line 118 of file aabbox3f.hpp.

◆ width()

float jau::math::geom::AABBox3f::width ( ) const
inlinenoexcept

Definition at line 120 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ height()

float jau::math::geom::AABBox3f::height ( ) const
inlinenoexcept

Definition at line 122 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ depth()

float jau::math::geom::AABBox3f::depth ( ) const
inlinenoexcept

Definition at line 124 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ volume()

float jau::math::geom::AABBox3f::volume ( ) const
inlinenoexcept

Returns the volume, i.e.

width * height * depth

Definition at line 127 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ hasZeroVolume()

bool jau::math::geom::AABBox3f::hasZeroVolume ( ) const
inlinenoexcept

Return true if getVolume() is FloatUtil#isZero(float), considering epsilon.

Definition at line 130 of file aabbox3f.hpp.

◆ area2D()

float jau::math::geom::AABBox3f::area2D ( ) const
inlinenoexcept

Returns the assumed 2D area, i.e.

width * height while assuming low and high lies on same plane.

Definition at line 133 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ hasZeroArea2D()

bool jau::math::geom::AABBox3f::hasZeroArea2D ( ) const
inlinenoexcept

Return true if get2DArea() is FloatUtil#isZero(float), considering epsilon.

Definition at line 136 of file aabbox3f.hpp.

◆ setSize() [1/3]

AABBox3f & jau::math::geom::AABBox3f::setSize ( const float  low[],
const float  high[] 
)
inlinenoexcept

Set size of the aabbox3f specifying the coordinates of the low and high.

Parameters
lowmin xyz-coordinates
highmax xyz-coordinates
Returns
this aabbox3f for chaining

Definition at line 146 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ setSize() [2/3]

AABBox3f & jau::math::geom::AABBox3f::setSize ( const float  lx,
const float  ly,
const float  lz,
const float  hx,
const float  hy,
const float  hz 
)
inlinenoexcept

Set size of the aabbox3f specifying the coordinates of the low and high.

Parameters
lxmin x-coordinate
lymin y-coordnate
lzmin z-coordinate
hxmax x-coordinate
hymax y-coordinate
hzmax z-coordinate
Returns
this aabbox3f for chaining

Definition at line 162 of file aabbox3f.hpp.

◆ setSize() [3/3]

AABBox3f & jau::math::geom::AABBox3f::setSize ( const Vec3f low,
const Vec3f high 
)
inlinenoexcept

Set size of the aabbox3f specifying the coordinates of the low and high.

Parameters
lowmin xyz-coordinates
highmax xyz-coordinates
Returns
this aabbox3f for chaining

Definition at line 178 of file aabbox3f.hpp.

◆ resizeWidth()

AABBox3f & jau::math::geom::AABBox3f::resizeWidth ( const float  deltaLeft,
const float  deltaRight 
)
inlinenoexcept

Resize width of this aabbox3f with explicit left- and right delta values.

Parameters
deltaLeftpositive value will expand width, otherwise shrink width
deltaRightpositive value will expand width, otherwise shrink width
Returns
this aabbox3f for chaining

Definition at line 191 of file aabbox3f.hpp.

◆ resizeHeight()

AABBox3f & jau::math::geom::AABBox3f::resizeHeight ( const float  deltaBottom,
const float  deltaTop 
)
inlinenoexcept

Resize height of this aabbox3f with explicit bottom- and top delta values.

Parameters
deltaBottompositive value will expand height, otherwise shrink height
deltaToppositive value will expand height, otherwise shrink height
Returns
this aabbox3f for chaining

Definition at line 213 of file aabbox3f.hpp.

◆ resize() [1/5]

AABBox3f & jau::math::geom::AABBox3f::resize ( const AABBox3f o)
inlinenoexcept

Resize the aabbox3f to encapsulate another AABox.

Parameters
newBoxaabbox3f to be encapsulated in
Returns
this aabbox3f for chaining

Definition at line 234 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ resize() [2/5]

AABBox3f & jau::math::geom::AABBox3f::resize ( const AABBox3f newBox,
transform_vec3f_func transform 
)
inlinenoexcept

Resize the aabbox3f to encapsulate another AABox, which will be transformed on the fly first.

Parameters
newBoxaabbox3f to be encapsulated in
transformthe transform function, applied on newBox on the fly
tmpV3temporary storage
Returns
this aabbox3f for chaining

Definition at line 272 of file aabbox3f.hpp.

◆ resize() [3/5]

AABBox3f & jau::math::geom::AABBox3f::resize ( const float  x,
const float  y,
const float  z 
)
inlinenoexcept

Resize the aabbox3f to encapsulate the passed xyz-coordinates.

Parameters
xx-axis coordinate value
yy-axis coordinate value
zz-axis coordinate value
Returns
this aabbox3f for chaining

Definition at line 312 of file aabbox3f.hpp.

◆ resize() [4/5]

AABBox3f & jau::math::geom::AABBox3f::resize ( const float  xyz[])
inlinenoexcept

Resize the aabbox3f to encapsulate the passed xyz-coordinates.

Parameters
xyzxyz-axis coordinate values
Returns
this aabbox3f for chaining

Definition at line 344 of file aabbox3f.hpp.

◆ resize() [5/5]

AABBox3f & jau::math::geom::AABBox3f::resize ( const Point3f p)
inlinenoexcept

Resize the aabbox3f to encapsulate the passed xyz-coordinates.

Parameters
xyzxyz-axis coordinate values
Returns
this aabbox3f for chaining

Definition at line 354 of file aabbox3f.hpp.

◆ contains() [1/5]

bool jau::math::geom::AABBox3f::contains ( const float  x,
const float  y 
) const
inlinenoexcept

Check if the 2D point is bounded/contained by this aabbox3f.

Returns
true if {x, y} belongs to {low, high}

Definition at line 362 of file aabbox3f.hpp.

◆ contains() [2/5]

bool jau::math::geom::AABBox3f::contains ( const Point2f p) const
inlinenoexcept

Check if the 2D point is bounded/contained by this aabbox3f.

Returns
true if p belongs to {low, high}

Definition at line 371 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ contains() [3/5]

bool jau::math::geom::AABBox3f::contains ( const float  x,
const float  y,
const float  z 
) const
inlinenoexcept

Check if the 3D point is bounded/contained by this aabbox3f.

Returns
true if {x, y, z} belongs to {low, high}

Definition at line 377 of file aabbox3f.hpp.

◆ contains() [4/5]

bool jau::math::geom::AABBox3f::contains ( const Point3f p) const
inlinenoexcept

Check if the 3D point is bounded/contained by this aabbox3f.

Returns
true if p belongs to (low.x, high.x) and y belong to (low.y, high.y)

Definition at line 387 of file aabbox3f.hpp.

Here is the caller graph for this function:

◆ intersects()

bool jau::math::geom::AABBox3f::intersects ( const AABBox3f o) const
inlinenoexcept

Returns whether this aabbox3f intersects (partially contains) given aabbox3f.

Definition at line 390 of file aabbox3f.hpp.

◆ contains() [5/5]

bool jau::math::geom::AABBox3f::contains ( const AABBox3f o) const
inlinenoexcept

Returns whether this aabbox3f fully contains given aabbox3f.

Definition at line 400 of file aabbox3f.hpp.

◆ intersects2DRegion()

bool jau::math::geom::AABBox3f::intersects2DRegion ( const float  x,
const float  y,
const float  w,
const float  h 
) const
inlinenoexcept

Check if there is a common region between this AABBox and the passed 2D region irrespective of z range.

Parameters
xlower left x-coord
ylower left y-coord
wwidth
hhight
Returns
true if this AABBox might have a common region with this 2D region

Definition at line 418 of file aabbox3f.hpp.

◆ intersectsRay()

bool jau::math::geom::AABBox3f::intersectsRay ( const Ray3f  ray) const
inlinenoexcept

Check if Ray intersects this bounding box.

Versions uses the SAT[1], testing 6 axes. Original code for OBBs from MAGIC. Rewritten for AABBs and reorganized for early exits[2].

[1] SAT = Separating Axis Theorem
[2] http://www.codercorner.com/RayAABB.cpp
Parameters
ray
Returns

Definition at line 449 of file aabbox3f.hpp.

◆ getRayIntersection()

bool jau::math::geom::AABBox3f::getRayIntersection ( Vec3f result,
const Ray3f ray,
const float  epsilon,
const bool  assumeIntersection 
)
inline

Return intersection of a Ray with this bounding box, or false if none exist.

  • Original code by Andrew Woo, from "Graphics Gems", Academic Press, 1990 [2]
  • Optimized code by Pierre Terdiman, 2000 (~20-30% faster on my Celeron 500)
  • Epsilon value added by Klaus Hartmann.

Method is based on the requirements:

  • the integer representation of 0.0f is 0x00000000
  • the sign bit of the float is the most significant one

Report bugs: p.ter.nosp@m.dima.nosp@m.n@cod.nosp@m.erco.nosp@m.rner..nosp@m.com (original author)

[1] http://www.codercorner.com/RayAABB.cpp
[2] http://tog.acm.org/resources/GraphicsGems/gems/RayBox.c
Parameters
resultvec3
ray
epsilon
assumeIntersectionif true, method assumes an intersection, i.e. by pre-checking via intersectsRay(Ray). In this case method will not validate a possible non-intersection and just computes coordinates.
Returns
true with having intersection coordinates stored in result, or false if none exists

Definition at line 517 of file aabbox3f.hpp.

◆ toString()

std::string jau::math::geom::AABBox3f::toString ( ) const
inlinenoexcept

Definition at line 681 of file aabbox3f.hpp.


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