68 const float bound = std::numeric_limits<float>::infinity();
69 min =
AtVector( bound, bound, bound);
70 max =
AtVector(-bound, -bound, -bound);
87 return AiAll(p >= min) && AiAll(p <= max);
95 return (max.x - min.x) * (max.y - min.y) * (max.z - min.z);
103 return AiAny(min > max);
112 return diag.x * (diag.y + diag.z) + diag.y * diag.z;
128 return (max + min) * 0.5f;
172 constexpr AtBBox2(
int min_x,
int min_y,
int max_x,
int max_y) :
173 minx(min_x), miny(min_y), maxx(max_x), maxy(max_y) {}
180 return (maxx - minx + 1) * (maxy - miny + 1);
183 int minx, miny, maxx, maxy;
190static 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:149
AI_DEVICE bool inside(const AtVector &p) const
Check to see if the specified point is inside the bbox.
Definition: ai_bbox.h:85
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:159
AI_DEVICE void addSlack(float slack)
Expand a bounding box with some safety slack volume.
Definition: ai_bbox.h:57
float volume() const
Compute the volume of a bbox.
Definition: ai_bbox.h:93
AI_DEVICE AtVector center() const
Compute the center of a bbox.
Definition: ai_bbox.h:126
constexpr int AiBBox2Area() const
Compute the area (# of pixels) of an integer bbox.
Definition: ai_bbox.h:178
AtBBox AiBBoxUnion(const AtBBox &b1, const AtBBox &b2)
Compute the "union" of two bboxes.
Definition: ai_bbox.h:140
bool isEmpty() const
Returns whether or not the specified box is empty.
Definition: ai_bbox.h:101
float area() const
Compute the surface area of a bbox.
Definition: ai_bbox.h:118
void expand(const AtVector &v)
Expand a bounding box with a point.
Definition: ai_bbox.h:76
float halfArea() const
Compute half the surface area of a bbox.
Definition: ai_bbox.h:109
void init()
Initialize a bounding box to be empty.
Definition: ai_bbox.h:66
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:169
3D axis-aligned bounding box (uses single-precision)
Definition: ai_bbox.h:33
3D point (single precision)
Definition: ai_vector.h:30