jaulib v1.3.8
Jau Support Library (C++, Java, ..)
|
Axis Aligned Bounding Box. More...
#include <aabbox3f.hpp>
Public Types | |
typedef jau::function< jau::math::Vec3f(const jau::math::Vec3f &)> | transform_vec3f_func |
General purpose Vec3f transform function. | |
Public Member Functions | |
AABBox3f () noexcept | |
Create an Axis Aligned bounding box (aabbox3f) where the low and and high MAX float Values. | |
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) | |
float | area2D () const noexcept |
Returns the assumed 2D area, i.e. | |
const Point3f & | center () const noexcept |
Returns computed center of this aabbox3f of low() and high(). | |
bool | contains (const AABBox3f &o) const noexcept |
Returns whether this aabbox3f fully contains given aabbox3f. | |
bool | contains (const float x, const float y) const noexcept |
Check if the 2D point is bounded/contained by this aabbox3f. | |
bool | contains (const float x, const float y, const float z) const noexcept |
Check if the 3D point is bounded/contained by this aabbox3f. | |
bool | contains (const Point2f &p) const noexcept |
Check if the 2D point is bounded/contained by this aabbox3f. | |
bool | contains (const Point3f &p) const noexcept |
Check if the 3D point is bounded/contained by this aabbox3f. | |
float | depth () const noexcept |
bool | getRayIntersection (Vec3f &result, const Ray3f &ray, const float epsilon, const bool assumeIntersection) const noexcept |
Return intersection of a Ray with this bounding box, or false if none exist. | |
bool | hasZeroArea2D () const noexcept |
Return true if get2DArea() is FloatUtil#isZero(float) , considering epsilon. | |
bool | hasZeroVolume () const noexcept |
Return true if getVolume() is FloatUtil#isZero(float) , considering epsilon. | |
float | height () const noexcept |
const Point3f & | high () const noexcept |
Returns the maximum right-top-near (xyz) coordinate. | |
bool | intersects (const AABBox3f &o) const noexcept |
Returns whether this aabbox3f intersects (partially contains) given aabbox3f. | |
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. | |
bool | intersectsRay (const Ray3f &r) const noexcept |
Check if Ray intersects this bounding box. | |
bool | intersectsRay0 (const Ray3f ray) const noexcept |
Check if Ray intersects this bounding box. | |
bool | intersectsRay1 (const Ray3f &r) const noexcept |
Check if Ray intersects this bounding box. | |
const Point3f & | low () const noexcept |
Returns the minimum left-bottom-far (xyz) coordinate. | |
AABBox3f & | mapToWindow (AABBox3f &result, const Mat4f &mat4PMv, const Recti &viewport, bool useCenterZ) const noexcept |
Assume this bounding box as being in object space and compute the window bounding box. | |
AABBox3f & | operator= (AABBox3f &&) noexcept=default |
AABBox3f & | operator= (const AABBox3f &) noexcept=default |
AABBox3f & | reset () noexcept |
Reset this box to the inverse low/high, allowing the next resize(float, float, float) command to hit. | |
AABBox3f & | resize (const AABBox3f &newBox, transform_vec3f_func &transform) noexcept |
Resize the aabbox3f to encapsulate another AABox, which will be transformed on the fly first. | |
AABBox3f & | resize (const AABBox3f &o) noexcept |
Resize the aabbox3f to encapsulate another AABox. | |
AABBox3f & | resize (const float x, const float y, const float z) noexcept |
Resize the aabbox3f to encapsulate the passed xyz-coordinates. | |
AABBox3f & | resize (const float xyz[]) noexcept |
Resize the aabbox3f to encapsulate the passed xyz-coordinates. | |
AABBox3f & | resize (const Point3f &p) noexcept |
Resize the aabbox3f to encapsulate the passed xyz-coordinates. | |
AABBox3f & | resizeHeight (const float deltaBottom, const float deltaTop) noexcept |
Resize height of this aabbox3f with explicit bottom- and top delta values. | |
AABBox3f & | resizeWidth (const float deltaLeft, const float deltaRight) noexcept |
Resize width of this aabbox3f with explicit left- and right delta values. | |
AABBox3f & | setSize (const float low[], const float high[]) noexcept |
Set size of the aabbox3f specifying the coordinates of the low and high. | |
AABBox3f & | setSize (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. | |
AABBox3f & | setSize (const Vec3f &low, const Vec3f &high) noexcept |
Set size of the aabbox3f specifying the coordinates of the low and high. | |
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. | |
std::string | toString () const noexcept |
AABBox3f & | transform (const Mat4f &mat, AABBox3f &out) const noexcept |
Transform this box using the given Mat4f into out @endiliteral. | |
float | volume () const noexcept |
Returns the volume, i.e. | |
float | width () const noexcept |
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 43 of file aabbox3f.hpp.
typedef jau::function<jau::math::Vec3f(const jau::math::Vec3f&)> jau::math::geom::AABBox3f::transform_vec3f_func |
General purpose Vec3f transform function.
Definition at line 257 of file aabbox3f.hpp.
|
inlinenoexcept |
Create an Axis Aligned bounding box (aabbox3f) where the low and and high MAX float Values.
Definition at line 57 of file aabbox3f.hpp.
Create an aabbox3f with given bl (low) and tr (high)
Definition at line 64 of file aabbox3f.hpp.
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
inlinenoexcept |
Reset this box to the inverse low/high, allowing the next resize(float, float, float)
command to hit.
Definition at line 91 of file aabbox3f.hpp.
|
inlinenoexcept |
Returns the maximum right-top-near (xyz) coordinate.
Definition at line 99 of file aabbox3f.hpp.
|
inlinenoexcept |
Returns the minimum left-bottom-far (xyz) coordinate.
Definition at line 102 of file aabbox3f.hpp.
|
inlinenoexcept |
Returns computed center of this aabbox3f of low() and high().
Definition at line 105 of file aabbox3f.hpp.
|
inlinenoexcept |
Get the size of this aabbox3f where the size is represented by the length of the vector between low and high.
Definition at line 112 of file aabbox3f.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Returns the volume, i.e.
width * height * depth
Definition at line 121 of file aabbox3f.hpp.
|
inlinenoexcept |
Return true if getVolume()
is FloatUtil#isZero(float)
, considering epsilon.
Definition at line 124 of file aabbox3f.hpp.
|
inlinenoexcept |
Returns the assumed 2D area, i.e.
width * height while assuming low and high lies on same plane.
Definition at line 127 of file aabbox3f.hpp.
|
inlinenoexcept |
Return true if get2DArea()
is FloatUtil#isZero(float)
, considering epsilon.
Definition at line 130 of file aabbox3f.hpp.
|
inlinenoexcept |
Set size of the aabbox3f specifying the coordinates of the low and high.
low | min xyz-coordinates |
high | max xyz-coordinates |
Definition at line 140 of file aabbox3f.hpp.
|
inlinenoexcept |
Set size of the aabbox3f specifying the coordinates of the low and high.
lx | min x-coordinate |
ly | min y-coordnate |
lz | min z-coordinate |
hx | max x-coordinate |
hy | max y-coordinate |
hz | max z-coordinate |
Definition at line 156 of file aabbox3f.hpp.
|
inlinenoexcept |
Set size of the aabbox3f specifying the coordinates of the low and high.
low | min xyz-coordinates |
high | max xyz-coordinates |
Definition at line 172 of file aabbox3f.hpp.
|
inlinenoexcept |
Resize width of this aabbox3f with explicit left- and right delta values.
deltaLeft | positive value will expand width, otherwise shrink width |
deltaRight | positive value will expand width, otherwise shrink width |
Definition at line 185 of file aabbox3f.hpp.
|
inlinenoexcept |
Resize height of this aabbox3f with explicit bottom- and top delta values.
deltaBottom | positive value will expand height, otherwise shrink height |
deltaTop | positive value will expand height, otherwise shrink height |
Definition at line 207 of file aabbox3f.hpp.
Resize the aabbox3f to encapsulate another AABox.
newBox | aabbox3f to be encapsulated in |
Definition at line 228 of file aabbox3f.hpp.
|
inlinenoexcept |
Resize the aabbox3f to encapsulate another AABox, which will be transformed on the fly first.
newBox | aabbox3f to be encapsulated in |
transform | the transform function, applied on newBox on the fly |
tmpV3 | temporary storage |
Definition at line 266 of file aabbox3f.hpp.
|
inlinenoexcept |
Resize the aabbox3f to encapsulate the passed xyz-coordinates.
x | x-axis coordinate value |
y | y-axis coordinate value |
z | z-axis coordinate value |
Definition at line 306 of file aabbox3f.hpp.
|
inlinenoexcept |
Resize the aabbox3f to encapsulate the passed xyz-coordinates.
xyz | xyz-axis coordinate values |
Definition at line 338 of file aabbox3f.hpp.
Resize the aabbox3f to encapsulate the passed xyz-coordinates.
xyz | xyz-axis coordinate values |
Definition at line 348 of file aabbox3f.hpp.
|
inlinenoexcept |
Check if the 2D point is bounded/contained by this aabbox3f.
Definition at line 356 of file aabbox3f.hpp.
|
inlinenoexcept |
Check if the 2D point is bounded/contained by this aabbox3f.
Definition at line 365 of file aabbox3f.hpp.
|
inlinenoexcept |
Check if the 3D point is bounded/contained by this aabbox3f.
Definition at line 371 of file aabbox3f.hpp.
|
inlinenoexcept |
Check if the 3D point is bounded/contained by this aabbox3f.
Definition at line 381 of file aabbox3f.hpp.
|
inlinenoexcept |
Returns whether this aabbox3f intersects (partially contains) given aabbox3f.
Definition at line 384 of file aabbox3f.hpp.
|
inlinenoexcept |
Returns whether this aabbox3f fully contains given aabbox3f.
Definition at line 402 of file aabbox3f.hpp.
|
inlinenoexcept |
Check if there is a common region between this AABBox and the passed 2D region irrespective of z range.
x | lower left x-coord |
y | lower left y-coord |
w | width |
h | hight |
Definition at line 420 of file aabbox3f.hpp.
|
inlinenoexcept |
Check if Ray
intersects this bounding box.
Versions uses the SAT[1], testing 6 axes with branching.
Original code for OBBs from MAGIC. Rewritten for AABBs and reorganized for early exits[2].
ray |
Definition at line 451 of file aabbox3f.hpp.
|
inlinenoexcept |
Check if Ray
intersects this bounding box.
Fast, Branchless Ray/Bounding Box Intersections[3]
This variant of intersectsRay() is a bit slower but handles NaNs more consistently.
The idea to eliminate branches by relying on IEEE 754 floating point properties goes back to Brian Smits[1], and the implementation was fleshed out by Amy Williams. et al.[2].
ray |
Definition at line 492 of file aabbox3f.hpp.
|
inlinenoexcept |
Check if Ray
intersects this bounding box.
Fast, Branchless Ray/Bounding Box Intersections[3]
This variant of intersectsRay0() is a faster and doesn't handles NaNs perfectly. However, it may only cause false positives, which will be checked later.
The idea to eliminate branches by relying on IEEE 754 floating point properties goes back to Brian Smits[1], and the implementation was fleshed out by Amy Williams. et al.[2].
ray |
Definition at line 533 of file aabbox3f.hpp.
|
inlinenoexcept |
Return intersection of a Ray
with this bounding box, or false if none exist.
Method is based on the requirements:
Report bugs: p.ter.nosp@m.dima.nosp@m.n@cod.nosp@m.erco.nosp@m.rner..nosp@m.com (original author)
result | vec3 |
ray | |
epsilon | |
assumeIntersection | if 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. |
Definition at line 578 of file aabbox3f.hpp.
|
inlinenoexcept |
Assume this bounding box as being in object space and compute the window bounding box.
If useCenterZ
is true
, only 4 mapObjToWinCoords
operations are made on points [1..4] using getCenter()
's z-value. Otherwise 8 mapObjToWinCoords
operation on all 8 points are performed.
.z() ------ [4] | | | | .y() ------ [3]
mat4PMv | [projection] x [modelview] matrix, i.e. P x Mv |
viewport | viewport rectangle |
useCenterZ | |
vec3Tmp0 | 3 component vector for temp storage |
vec4Tmp1 | 4 component vector for temp storage |
vec4Tmp2 | 4 component vector for temp storage |
Definition at line 803 of file aabbox3f.hpp.
|
inlinenoexcept |
Definition at line 840 of file aabbox3f.hpp.