59 constexpr float bound = std::numeric_limits<float>::infinity();
60 return {{bound, bound, bound}, {-bound, -bound, -bound}};
68 constexpr float bound = std::numeric_limits<float>::infinity();
69 return {{-bound, -bound, -bound}, {bound, bound, bound}};
86 const float bound = std::numeric_limits<float>::infinity();
87 min =
AtVector( bound, bound, bound);
88 max =
AtVector(-bound, -bound, -bound);
114 return AiAll(p >= min) && AiAll(p <= max);
122 return (max.x - min.x) * (max.y - min.y) * (max.z - min.z);
130 return AiAny(min > max);
139 return diag.x * (diag.y + diag.z) + diag.y * diag.z;
155 return (max + min) * 0.5f;
199 constexpr AtBBox2(
int min_x,
int min_y,
int max_x,
int max_y) :
200 minx(min_x), miny(min_y), maxx(max_x), maxy(max_y) {}
207 return (maxx - minx + 1) * (maxy - miny + 1);
210 AI_DEVICE
constexpr bool operator==(
const AtBBox2& bb)
const
212 return (minx == bb.minx && miny == bb.miny &&
213 maxx == bb.maxx && maxy == bb.maxy);
216 AI_DEVICE
constexpr bool operator!=(
const AtBBox2& bb)
const
218 return !(*
this == bb);
221 int minx, miny, maxx, maxy;
228static const AtBBox AI_BBOX_ZERO(AI_V3_ZERO, AI_V3_ZERO);
DLL export prefix for API functions (necessary for multi-platform development)
Vector math types, operators and utilities.
AtBBox AiBBoxIntersection(const AtBBox &b1, const AtBBox &b2)
Compute the intersection of two bboxes.
Definition: ai_bbox.h:176
AI_DEVICE bool inside(const AtVector &p) const
Check to see if the specified point is inside the bbox.
Definition: ai_bbox.h:112
static AI_DEVICE AtBBox infinity()
Convenience method returning infinitely large box.
Definition: ai_bbox.h:66
AtBBox AiBBoxLerp(float k, const AtBBox &lo, const AtBBox &hi)
Linear interpolation between two bboxes (k=0 -> bbox=lo, k=1 -> bbox=hi)
Definition: ai_bbox.h:186
AI_DEVICE void addSlack(float slack)
Expand a bounding box with some safety slack volume.
Definition: ai_bbox.h:75
float volume() const
Compute the volume of a bbox.
Definition: ai_bbox.h:120
AI_DEVICE AtVector center() const
Compute the center of a bbox.
Definition: ai_bbox.h:153
constexpr int AiBBox2Area() const
Compute the area (# of pixels) of an integer bbox.
Definition: ai_bbox.h:205
AtBBox AiBBoxUnion(const AtBBox &b1, const AtBBox &b2)
Compute the "union" of two bboxes.
Definition: ai_bbox.h:167
void expand(const AtBBox &b2)
Expand a bounding box with another bounding box.
Definition: ai_bbox.h:103
static AI_DEVICE AtBBox empty()
Convenience method returning empty box.
Definition: ai_bbox.h:57
bool isEmpty() const
Returns whether or not the specified box is empty.
Definition: ai_bbox.h:128
float area() const
Compute the surface area of a bbox.
Definition: ai_bbox.h:145
void expand(const AtVector &v)
Expand a bounding box with a point.
Definition: ai_bbox.h:94
float halfArea() const
Compute half the surface area of a bbox.
Definition: ai_bbox.h:136
void init()
Initialize a bounding box to be empty.
Definition: ai_bbox.h:84
AI_DEVICE constexpr AtVector AiV3Min(const AtVector &a, const AtVector &b)
Minimum of two vectors, component-wise.
Definition: ai_vector.h:696
AI_DEVICE constexpr AtVector AiV3Max(const AtVector &a, const AtVector &b)
Maximum of two vectors, component-wise.
Definition: ai_vector.h:706
AI_DEVICE constexpr AtVector AiV3Lerp(float t, const AtVector &lo, const AtVector &hi)
3D vector linear interpolation (t=0 -> result=lo, t=1 -> result=hi)
Definition: ai_vector.h:678
2D axis-aligned bounding box (uses integers)
Definition: ai_bbox.h:196
3D axis-aligned bounding box (uses single-precision)
Definition: ai_bbox.h:33
3D point (single precision)
Definition: ai_vector.h:30