32 #ifndef AABB_INCLUDE_ONCE 33 #define AABB_INCLUDE_ONCE 51 AABB(
const vec3& center, real radius );
54 AABB(
const vec3& pt1,
const vec3& pt2, real displace=0);
60 bool isNull()
const {
return mMin.x() > mMax.x() || mMin.y() > mMax.y() || mMin.z() > mMax.z(); }
63 bool isPoint()
const {
return mMin == mMax; }
67 void enlarge(real displace);
70 bool intersects(
const AABB & bb)
const;
73 vec3 clip(
const vec3& p,
bool clipx=
true,
bool clipy=
true,
bool clipz=
true)
const;
77 bool isInside(
const vec3& p,
bool clipx,
bool clipy,
bool clipz)
const;
80 bool isInside(
const vec3& p)
const;
94 return mMin == aabb.
mMin && mMax == aabb.
mMax;
109 *
this = *
this + other;
144 void addPoint(
const vec3& p, real radius);
156 if ( mMax.x() < p.
x() ) mMax.
x() = p.
x();
157 if ( mMax.y() < p.
y() ) mMax.y() = p.
y();
158 if ( mMax.z() < p.
z() ) mMax.z() = p.
z();
159 if ( mMin.x() > p.
x() ) mMin.x() = p.
x();
160 if ( mMin.y() > p.
y() ) mMin.y() = p.
y();
161 if ( mMin.z() > p.
z() ) mMin.z() = p.
z();
170 out.
addPoint( mat *
vec3(minCorner().x(), minCorner().y(), minCorner().z()) );
171 out.
addPoint( mat *
vec3(minCorner().x(), maxCorner().y(), minCorner().z()) );
172 out.
addPoint( mat *
vec3(maxCorner().x(), maxCorner().y(), minCorner().z()) );
173 out.
addPoint( mat *
vec3(maxCorner().x(), minCorner().y(), minCorner().z()) );
174 out.
addPoint( mat *
vec3(minCorner().x(), minCorner().y(), maxCorner().z()) );
175 out.
addPoint( mat *
vec3(minCorner().x(), maxCorner().y(), maxCorner().z()) );
176 out.
addPoint( mat *
vec3(maxCorner().x(), maxCorner().y(), maxCorner().z()) );
177 out.
addPoint( mat *
vec3(maxCorner().x(), minCorner().y(), maxCorner().z()) );
185 transformed(aabb, mat);
196 void setMinCorner(real x, real y, real z) { mMin.x() = x; mMin.y() = y; mMin.z() = z; }
202 void setMaxCorner(real x, real y, real z) { mMax.x() = x; mMax.y() = y; mMax.z() = z; }
208 real
volume()
const {
return width() * height() * depth(); }
AABB transformed(const mat4 &mat) const
Returns the AABB transformed by the given matrix.
bool operator==(const AABB &aabb) const
Returns true if two AABB are identical.
float operator+(float a, const half &b)
real longestSideLength() const
Returns the longest dimension of the AABB.
void setMaxCorner(const vec3 &v)
Sets the corner of the AABB with the maximum x y z coordinates.
bool isNull() const
Returns true if the AABB is null.
bool isPoint() const
Returns true if the AABB contains a single point, that is, if the min and max corners of the AABB are...
const T_Scalar & z() const
void setMinCorner(const vec3 &v)
Sets the corner of the AABB with the minimum x y z coordinates.
AABB & operator+=(const AABB &other)
Enlarges (if necessary) an AABB so that it contains the given AABB.
void setNull()
Sets ths AABB as null, that is, empty.
const AABB & operator+=(const vec3 &p)
Enlarges (if necessary) an AABB to contain the given point.
Visualization Library main namespace.
void transformed(AABB &out, const mat4 &mat) const
Transforms an AABB by the given matrix and returns it into the out parameter.
The AABB class implements an axis-aligned bounding box using vl::real precision.
AABB operator+(const vec3 &p)
Returns an AABB which contains the source AABB and the given point.
const vec3 & maxCorner() const
Returns the corner of the AABB with the maximum x y z coordinates.
void setMinCorner(real x, real y, real z)
Sets the corner of the AABB with the minimum x y z coordinates.
void setMaxCorner(real x, real y, real z)
Sets the corner of the AABB with the maximum x y z coordinates.
void addPoint(const vec3 &p, real radius)
Updates the AABB to contain the given point.
const T_Scalar & y() const
void addPoint(const vec3 &p)
Updates the AABB to contain the given point.
const vec3 & minCorner() const
Returns the corner of the AABB with the minimum x y z coordinates.
fvec3 vec3
Defined as: 'typedef fvec3 vec3'. See also VL_PIPELINE_PRECISION.
bool operator==(const ref< T1 > &o1, const ref< T2 > &o2)
const T_Scalar & x() const
real volume() const
Returns the volume of the AABB.
bool operator!=(const AABB &aabb) const
Returns true if two AABB are not identical.