Thea
|
An axis-aligned box in N-dimensional space, where N is any positive (non-zero) integer and T is a field. More...
#include <AxisAlignedBoxN.hpp>
Public Types | |
typedef AxisAlignedBoxN< N, T > | AxisAlignedBoxT |
N-dimensional axis-aligned box. More... | |
Public Member Functions | |
void | addPoint (VectorT const &p) |
Grow to include a point. More... | |
AxisAlignedBoxN () | |
Default constructor, creates a null box. More... | |
AxisAlignedBoxN (VectorT const &v) | |
Constructor. More... | |
AxisAlignedBoxN (VectorT const &lo_, VectorT const &hi_) | |
Constructor. More... | |
template<typename U > | |
AxisAlignedBoxN< N, U > | cast () const |
Cast the box to a different scalar type. More... | |
VectorT | closestPoint (VectorT const &p) const |
Get the point in this box closest to a given point. More... | |
bool | contains (VectorT const &p) const |
Test if this box contains a point. More... | |
bool | contains (AxisAlignedBoxT const &other) const |
Test if this box contains another. More... | |
T | distance (AxisAlignedBoxT const &other) const |
Get the closest distance between this box and another one. More... | |
T | distance (VectorT const &point) const |
Get the closest distance to a point. More... | |
T | distance (LineN< N, T > const &line) const |
Get the distance between this box and an infinite line. More... | |
T | distance (LineSegmentN< N, T > const &seg) const |
Get the distance between this box and a line segment. More... | |
T | distance (RayN< N, T > const &ray) const |
Get the distance between this box and a ray. More... | |
VectorT | getCenter () const |
Get the center of the box. More... | |
VectorT | getExtent () const |
Get the extent of the box. More... | |
VectorT const & | getHigh () const |
Get the maximum corner of the box. More... | |
VectorT const & | getLow () const |
Get the minimum corner of the box. More... | |
VectorT | getVertex (uintx i) const |
Get the i'th corner vertex of the box, for i in the range [0, 2^N - 1]. More... | |
bool | intersects (VectorT const &p) const |
Test if this box intersects (i.e. More... | |
bool | intersects (AxisAlignedBoxT const &other) const |
Test if this box intersects another. More... | |
bool | isNull () const |
Check if the box is null. More... | |
T | maxDistance (VectorT const &point) const |
Get the largest distance between points of this box and a given point. More... | |
void | merge (VectorT const &p) |
Grow to include a point. More... | |
void | merge (AxisAlignedBoxT const &aab) |
Grow to include a box. More... | |
bool | operator== (AxisAlignedBoxNBase const &other) const |
Check if two boxes are equal. More... | |
RayIntersectionN< N, T > | rayIntersection (RayN< N, T > const &ray, T max_time=-1) const |
Get the intersection of a ray with the object, including the hit time and the normal at the intersection point. More... | |
T | rayIntersectionTime (RayN< N, T > const &ray, T max_time=-1) const |
Get the time taken for a ray to intersect the object, or a negative value if there was no intersection in the forward direction. More... | |
bool | rayIntersects (RayN< N, T > const &ray, T max_time=-1) const |
Check if a ray intersects the object in the forward direction. More... | |
void | scaleCentered (T const &scale) |
Scale the box by a linear factor relative to its center. More... | |
void | scaleCentered (VectorT const &scale) |
Scale the box relative to its center. More... | |
AxisAlignedBoxT | scaleCenteredCopy (T const &scale) const |
Return a box that is a copy of this, scaled by a linear factor relative to its center. More... | |
AxisAlignedBoxT | scaleCenteredCopy (VectorT const &scale) const |
Return a box that is a copy of this, scaled relative to its center. More... | |
void | set (VectorT const &lo_, VectorT const &hi_) |
Set the corners of the box. More... | |
void | setCenter (VectorT const ¢er) |
Set the center of the box, without changing its size. More... | |
void | setExtent (VectorT const &ext) |
Set the extent (size) of the box, without changing its center. More... | |
void | setNull () |
Set the box to be null. More... | |
T | squaredDistance (AxisAlignedBoxT const &other) const |
Get the square of the closest distance between this box and another one. More... | |
T | squaredDistance (VectorT const &point) const |
Get the square of the closest distance to a point. More... | |
T | squaredDistance (LineN< N, T > const &line, VectorT *this_pt=nullptr, VectorT *line_pt=nullptr) const |
Get the squared distance between this box and an infinite line, and optionally return the closest pair of points. More... | |
T | squaredDistance (LineSegmentN< N, T > const &seg, VectorT *this_pt=nullptr, VectorT *seg_pt=nullptr) const |
Get the squared distance between this box and a line segment, and optionally return the closest pair of points. More... | |
T | squaredDistance (RayN< N, T > const &ray, VectorT *this_pt=nullptr, VectorT *ray_pt=nullptr) const |
Get the squared distance between this box and a ray, and optionally return the closest pair of points. More... | |
T | squaredMaxDistance (VectorT const &point) const |
Get the square of the largest distance between points of this box and a given point. More... | |
std::string | toString () const |
Get a string representing the box as "[low, high]", or "[null]" if the box is null. More... | |
template<typename TransformT > | |
AxisAlignedBoxT | transformAndBound (TransformT const &tr) const |
Transform the box and return a new axis-aligned box which tightly encloses the result. More... | |
T | volume () const |
Get the volume of the box. More... | |
An axis-aligned box in N-dimensional space, where N is any positive (non-zero) integer and T is a field.
Definition at line 30 of file AxisAlignedBoxN.hpp.
|
inherited |
N-dimensional axis-aligned box.
Definition at line 44 of file AxisAlignedBoxN.hpp.
AxisAlignedBoxN | ( | ) |
Default constructor, creates a null box.
Definition at line 510 of file AxisAlignedBoxN.hpp.
AxisAlignedBoxN | ( | VectorT const & | v | ) |
AxisAlignedBoxN | ( | VectorT const & | lo_, |
VectorT const & | hi_ | ||
) |
|
inherited |
Grow to include a point.
Alias for merge(VectorT const &), for use with PointCollectorN.
Definition at line 171 of file AxisAlignedBoxN.hpp.
|
inherited |
Cast the box to a different scalar type.
Definition at line 63 of file AxisAlignedBoxN.hpp.
Get the point in this box closest to a given point.
Definition at line 349 of file AxisAlignedBoxN.hpp.
|
inherited |
Test if this box contains a point.
Definition at line 291 of file AxisAlignedBoxN.hpp.
|
inherited |
Test if this box contains another.
Null boxes do not contain or are contained by other boxes.
Definition at line 305 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the closest distance between this box and another one.
Returns zero if either box is null.
Definition at line 335 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the closest distance to a point.
Returns zero if the box is null.
Definition at line 355 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the distance between this box and an infinite line.
Definition at line 370 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the distance between this box and a line segment.
Definition at line 379 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the distance between this box and a ray.
Definition at line 388 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the center of the box.
The return value is zero for null boxes.
Definition at line 193 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the extent of the box.
The return value is zero for null boxes.
Definition at line 207 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the maximum corner of the box.
The return value is zero if the box is null.
Definition at line 95 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the minimum corner of the box.
The return value is zero if the box is null.
Definition at line 92 of file AxisAlignedBoxN.hpp.
Get the i'th corner vertex of the box, for i in the range [0, 2^N - 1].
This function works as expected only if N <= sizeof(uintx). The d'th coordinate of the returned point is assigned the d'th coordinate of the maximum corner of the box if the d'th bit of i (where the 0'th bit is the least significant) is 1, and of the minimum corner if it is 0.
Definition at line 110 of file AxisAlignedBoxN.hpp.
|
inherited |
Test if this box intersects (i.e.
contains) a point.
Definition at line 275 of file AxisAlignedBoxN.hpp.
|
inherited |
Test if this box intersects another.
Null boxes do not intersect each other.
Definition at line 278 of file AxisAlignedBoxN.hpp.
|
inherited |
Check if the box is null.
A null box has no extent or location in space. It is not equivalent to a box with zero extent. All null boxes are considered equal.
Definition at line 78 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the largest distance between points of this box and a given point.
Returns zero if the box is null.
Definition at line 358 of file AxisAlignedBoxN.hpp.
|
inherited |
Grow to include a point.
Equivalent to assignment if this box is initially null.
Definition at line 156 of file AxisAlignedBoxN.hpp.
|
inherited |
Grow to include a box.
Equivalent to assignment if this box is initially null. No-op if the argument is a null box.
Definition at line 174 of file AxisAlignedBoxN.hpp.
|
inherited |
Check if two boxes are equal.
Null boxes are considered to be equal to each other.
Definition at line 69 of file AxisAlignedBoxN.hpp.
|
virtualinherited |
Get the intersection of a ray with the object, including the hit time and the normal at the intersection point.
A negative time is returned if there was no intersection in the forward direction. If the normal cannot be computed, the zero vector is returned.
ray | The ray to test for intersection. |
max_time | Maximum allowable hit time, ignored if negative. |
Reimplemented from RayIntersectableN< N, T >.
Definition at line 420 of file AxisAlignedBoxN.hpp.
|
virtualinherited |
Get the time taken for a ray to intersect the object, or a negative value if there was no intersection in the forward direction.
All subclasses must reimplement this method. If the return value is negative, it should be at least
ray | The ray to test for intersection. |
max_time | Maximum allowable hit time, ignored if negative. |
Implements RayIntersectableN< N, T >.
Definition at line 413 of file AxisAlignedBoxN.hpp.
|
virtualinherited |
Check if a ray intersects the object in the forward direction.
ray | The ray to test for intersection. |
max_time | Maximum allowable hit time, ignored if negative. |
Reimplemented from RayIntersectableN< N, T >.
Definition at line 407 of file AxisAlignedBoxN.hpp.
|
inherited |
Scale the box by a linear factor relative to its center.
No-op if the box is null.
Definition at line 235 of file AxisAlignedBoxN.hpp.
|
inherited |
Scale the box relative to its center.
No-op if the box is null.
Definition at line 246 of file AxisAlignedBoxN.hpp.
|
inherited |
Return a box that is a copy of this, scaled by a linear factor relative to its center.
Definition at line 257 of file AxisAlignedBoxN.hpp.
|
inherited |
Return a box that is a copy of this, scaled relative to its center.
Definition at line 266 of file AxisAlignedBoxN.hpp.
Set the corners of the box.
Definition at line 98 of file AxisAlignedBoxN.hpp.
|
inherited |
Set the center of the box, without changing its size.
No-op if the box is null.
Definition at line 196 of file AxisAlignedBoxN.hpp.
|
inherited |
Set the extent (size) of the box, without changing its center.
No-op if the box is null.
Definition at line 210 of file AxisAlignedBoxN.hpp.
|
inherited |
|
inherited |
Get the square of the closest distance between this box and another one.
Returns zero if either box is null.
Definition at line 319 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the square of the closest distance to a point.
Returns zero if the box is null.
Definition at line 338 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the squared distance between this box and an infinite line, and optionally return the closest pair of points.
Definition at line 373 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the squared distance between this box and a line segment, and optionally return the closest pair of points.
Definition at line 382 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the squared distance between this box and a ray, and optionally return the closest pair of points.
Definition at line 391 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the square of the largest distance between points of this box and a given point.
Returns zero if the box is null.
Definition at line 361 of file AxisAlignedBoxN.hpp.
|
inherited |
Get a string representing the box as "[low, high]", or "[null]" if the box is null.
Definition at line 397 of file AxisAlignedBoxN.hpp.
|
inherited |
Transform the box and return a new axis-aligned box which tightly encloses the result.
Algorithm derived from the Ogre source code, http://www.ogre3d.org.
Definition at line 124 of file AxisAlignedBoxN.hpp.
|
inherited |
Get the volume of the box.
A null box has zero volume.
Definition at line 222 of file AxisAlignedBoxN.hpp.