45template <
typename T, Size DIM>
72template <
typename T, Size DIM>
114 for(
Size i = 0; i < DIM; i++) {
207 template <
typename InputIterator>
214 template <
typename T2>
223 template <
typename T2>
290 for(
Size i = 0; i < DIM; i++) {
308 for(
Size i = 0; i < DIM; i++)
334 for(
Size i = 0; i < DIM; i++) {
335 if( vec[i] <
min[i] || vec[i] >
max[i])
345 for(
Size i = 0; i < DIM; i++) {
373 template <
typename InputIterator>
422 for(
Size i = 1; i < DIM; i++)
444 for(
Size i = 1; i < DIM; i++) {
445 if (maxval < diag[i]) {
467template <
typename T, Size DIM>
472 for(
Size i = 0; i < DIM; i++) {
473 (result.
min)[i] = (bbox.
min)[i] - value;
474 (result.
max)[i] = (bbox.
max)[i] + value;
483template <
typename T, Size DIM>
488 for(
Size i = 0; i < DIM; i++) {
489 (result.
min)[i] = (bbox.
min)[i] + value;
490 (result.
max)[i] = (bbox.
max)[i] - value;
499template <
typename T, Size DIM>
504 for(
Size i = 0; i < DIM; i++) {
505 (result.
min)[i] = (bbox.
min)[i] * factor;
506 (result.
max)[i] = (bbox.
max)[i] * factor;
515template <
typename T, Size DIM>
521 for(
Size i = 0; i < DIM; i++) {
522 (result.
min)[i] = (bbox.
min)[i] / divisor;
523 (result.
max)[i] = (bbox.
max)[i] / divisor;
532template <
typename T, Size DIM>
536 for(
Size i = 0; i < DIM; i++) {
537 (bbox.
min)[i] -= value;
538 (bbox.
max)[i] += value;
547template <
typename T, Size DIM>
551 for(
Size i = 0; i < DIM; i++) {
552 (bbox.
min)[i] += value;
553 (bbox.
max)[i] -= value;
561template <
typename T, Size DIM>
565 for(
Size i = 0; i < DIM; i++) {
566 (bbox.
min)[i] *= factor;
567 (bbox.
max)[i] *= factor;
575template <
typename T, Size DIM>
580 for(
Size i = 0; i < DIM; i++) {
581 (bbox.
min)[i] /= divisor;
582 (bbox.
max)[i] /= divisor;
588template <
typename T, Size DIM>
591 return (lhs.
min) == (rhs.
min) && (lhs.
max) == (rhs.
max);
595template <
typename T, Size DIM>
598 return (lhs.
min) != (rhs.
min) || (lhs.
max) != (rhs.
max);
604template <
typename T, Size DIM>
607 for(
Size i(0u); i < DIM; ++i) {
608 if( (lhs.
min)[i] < (rhs.
min)[i])
610 if( (lhs.
min)[i] > (rhs.
min)[i])
619template <
typename T, Size DIM>
622 for(
Size i(0u); i < DIM; ++i) {
623 if( (lhs.
min)[i] < (rhs.
min)[i])
625 if( (lhs.
min)[i] > (rhs.
min)[i])
634template <
typename T, Size DIM>
637 for(
Size i(0u); i < DIM; ++i) {
638 if( (lhs.
min)[i] > (rhs.
min)[i])
640 if( (lhs.
min)[i] < (rhs.
min)[i])
649template <
typename T, Size DIM>
652 for(
Size i(0u); i < DIM; ++i) {
653 if( (lhs.
min)[i] > (rhs.
min)[i])
655 if( (lhs.
min)[i] < (rhs.
min)[i])
669template <
typename T, Size DIM>
684template <
typename T, Size DIM>
690 for(
Size i = 0; i < DIM; i++) {
693 if (result.
max[i] < result.
min[i]) {
714template <
typename TT,
typename T>
715Bbox<T,3>
transform_point(
const Matrix<TT,4,4>& mat,
const Bbox<T,3>& bbox);
726template <
typename TT,
typename T>
727Bbox<T,3>
transform_vector(
const Matrix<TT,4,4>& mat,
const Bbox<T,3>& bbox);
733#ifndef MI_FOR_DOXYGEN_ONLY
735template <
typename T, Size DIM>
736template <
typename InputIterator>
739 for( ; first != last; ++first)
743template <
typename T, Size DIM>
744template <
typename InputIterator>
748 insert( first, last);
751template <
typename T, Size DIM>
765 for(
Size i = 0; i < DIM; i++)
770 for(
Size i = 0; i < DIM; i++)
772 const T margin = max_dist * eps;
779template <
typename TT,
typename T>
794 corners[0].x += T(mat.wx);
795 corners[0].y += T(mat.wy);
796 corners[0].z += T(mat.wz);
803 corners[1] = corners[0] + dz;
804 corners[2] = corners[0] + dy;
805 corners[3] = corners[0] + dy + dz;
806 corners[4] = corners[0] + dx;
807 corners[5] = corners[0] + dx + dz;
808 corners[6] = corners[0] + dx + dy;
809 corners[7] = corners[0] + dx + dy + dz;
815 T wx = T( mat.xw * ((bbox.
max).x - (bbox.
min).x));
816 T wy = T( mat.yw * ((bbox.
max).y - (bbox.
min).y));
817 T wz = T( mat.zw * ((bbox.
max).z - (bbox.
min).z));
820 w[0] = T(mat.xw * (bbox.
min).x + mat.yw * (bbox.
min).y + mat.zw * (bbox.
min).z + mat.ww);
823 w[3] = w[0] + wy + wz;
825 w[5] = w[0] + wx + wz;
826 w[6] = w[0] + wx + wy;
827 w[7] = w[0] + wx + wy + wz;
830 for(
unsigned int i=0; i<8; ++i) {
831 if( w[i]!=0 && w[i]!=1) {
842template <
typename TT,
typename T>
856 corners[1] = corners[0] + dz;
857 corners[2] = corners[0] + dy;
858 corners[3] = corners[0] + dy + dz;
859 corners[4] = corners[0] + dx;
860 corners[5] = corners[0] + dx + dz;
861 corners[6] = corners[0] + dx + dy;
862 corners[7] = corners[0] + dx + dy + dz;
Axis-aligned N-dimensional bounding box class template of fixed dimension.
Definition: bbox.h:74
NxM-dimensional matrix class template of fixed dimensions.
Definition: matrix.h:367
Fixed-size math vector class template with generic operations.
Definition: vector.h:286
Math functions and function templates on simple types or generic container and vector concepts.
#define mi_static_assert(expr)
Compile time assertion that raises a compilation error if the constant expression expr evaluates to f...
Definition: assert.h:58
#define MI_PREVENT_MACRO_EXPAND
Empty macro that can be used after function names to prevent macro expansion that happen to have the ...
Definition: config.h:97
static T negative_max() noexcept
Returns the smallest finite negative value for T.
Definition: types.h:404
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
Sint64 Difference
Signed integral type that is large enough to hold the difference of two pointers.
Definition: types.h:122
bool lexicographically_less(const V &lhs, const V &rhs)
Returns true if vector lhs is lexicographically less than vector rhs, and false otherwise.
Definition: function.h:1114
bool lexicographically_less_or_equal(const V &lhs, const V &rhs)
Returns true if vector lhs is lexicographically less than or equal to vector rhs, and false otherwise...
Definition: function.h:1130
bool lexicographically_greater_or_equal(const V &lhs, const V &rhs)
Returns true if vector lhs is lexicographically greater than or equal to vector rhs,...
Definition: function.h:1162
Float32 length(Float32 a)
Returns the Euclidean norm of the scalar a (its absolute value).
Definition: function.h:1047
bool lexicographically_greater(const V &lhs, const V &rhs)
Returns true if vector lhs is lexicographically greater than vector rhs, and false otherwise.
Definition: function.h:1146
#define mi_math_assert_msg(expr, msg)
Math API assertion macro (with message).
Definition: assert.h:80
bool operator>=(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is lexicographically greater than or equal to rhs.
Definition: bbox.h:650
Bbox(Uninitialized_tag)
Bounding box with its elements not initialized.
Definition: bbox.h:129
Bbox(T min_x, T min_y, T max_x, T max_y)
2D bounding box (interval) initialized to the new extreme corner vectors, (min_x,min_y) and (max_x,...
Definition: bbox.h:172
Vector max
Elementwise maximal bounding box corner.
Definition: bbox.h:104
Bbox<T, DIM> operator+(const Bbox<T, DIM> &bbox, T value)
Returns a bounding box that is the bbox increased by a constant value at each face,...
Definition: bbox.h:468
Vector extent() const
Returns the size of the bounding box.
Definition: bbox.h:457
void insert(InputIterator first, InputIterator last)
Inserts a range [first,last) of items into this bounding box.
bool operator<(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is lexicographically less than rhs.
Definition: bbox.h:605
Bbox add_motionbox(const Bbox &vbox, T t) const
Returns the translation of this bounding box by vectors that are inside the scaled bounding box of ve...
Definition: bbox.h:386
Bbox(const Vector &nmin, const Vector &nmax)
Bounding box initialized to the new extreme corner vectors, nmin and nmax.
Definition: bbox.h:148
void insert(const Vector &point)
Assigns the union of this bounding box and the point to this bounding box.
Definition: bbox.h:360
Bbox()
Bounding box initialized to the empty space, see also the clear function.
Definition: bbox.h:126
void robust_grow(T eps=T(1.0e-5f))
Robustly grows the bounding box by a value computed automatically from the bounding box dimensions an...
Size size_type
Size type, unsigned.
Definition: bbox.h:79
Bbox(const Bbox<T2, DIM> &other)
Template constructor that allows explicit conversions from other bounding boxes with assignment compa...
Definition: bbox.h:215
math::Vector<T, DIM> Vector
Corresponding vector type.
Definition: bbox.h:76
Vector center() const
Returns the center point of the bounding box.
Definition: bbox.h:454
bool is_volume() const
Returns true the bounding box has a volume.
Definition: bbox.h:329
Bbox<T, DIM> & operator*=(Bbox<T, DIM> &bbox, T factor)
Scales bbox by factor, i.e., bbox.max and bbox.min are multiplied by factor.
Definition: bbox.h:562
Bbox(const Vector &point)
Bounding box initialized to a single point.
Definition: bbox.h:142
void push_back(const Bbox &other)
Assigns the union of this bounding box and the other bounding box to this bounding box.
Definition: bbox.h:401
Difference difference_type
Difference type, signed.
Definition: bbox.h:80
Bbox<T, DIM> & operator+=(Bbox<T, DIM> &bbox, T value)
Increases bbox by a constant value at each face, i.e., value is added to bbox.max and subtracted from...
Definition: bbox.h:533
static const Size DIMENSION
Constant dimension of the vectors.
Definition: bbox.h:86
bool is_line() const
Returns true the bounding box is an axis-aligned line.
Definition: bbox.h:319
const Vector * end() const
Returns the past-the-end pointer.
Definition: bbox.h:269
Vector & operator[](Size i)
Returns the vector min for i==0, and the vector max for i==1.
Definition: bbox.h:272
Vector min
Elementwise minimal bounding box corner.
Definition: bbox.h:103
Bbox(const Bbox_struct<T2, DIM> &other)
Template constructor that allows explicit conversions from other POD type with assignment compatible ...
Definition: bbox.h:224
Bbox(T min_x, T min_y, T min_z, T max_x, T max_y, T max_z)
3D bounding box (interval) initialized to the new extreme corner vectors, (min_x,min_y,...
Definition: bbox.h:187
Bbox & operator=(const Bbox_struct<T, DIM> &other)
Assignment from corresponding POD type.
Definition: bbox.h:239
bool operator==(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is elementwise equal to rhs.
Definition: bbox.h:589
Bbox & operator=(const Bbox &other)
Assignment.
Definition: bbox.h:231
static Size max_size()
Constant maximum size of the bounding box.
Definition: bbox.h:93
Vector * end()
Returns the past-the-end pointer.
Definition: bbox.h:264
T volume() const
Returns the volume of the bounding box.
Definition: bbox.h:418
bool operator>(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is lexicographically greater than rhs.
Definition: bbox.h:635
Bbox<T, DIM> & operator/=(Bbox<T, DIM> &bbox, T divisor)
Divide bbox by divisor, i.e., bbox.max and bbox.min are divided by divisor.
Definition: bbox.h:576
Bbox(InputIterator first, InputIterator last)
Constructs a bounding box from a range [first, last) of items.
Bbox<T, DIM> operator/(const Bbox<T, DIM> &bbox, T divisor)
Returns a bounding box that is a version of bbox divided by divisor, i.e., bbox.max and bbox....
Definition: bbox.h:516
Bbox<T, DIM> clip(const Bbox<T, DIM> &bbox1, const Bbox<T, DIM> &bbox2)
Clip bbox1 at bbox2 and return the result.
Definition: bbox.h:685
bool operator!=(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is elementwise not equal to rhs.
Definition: bbox.h:596
bool empty() const
Returns true if the box is empty.
Definition: bbox.h:288
Uninitialized_tag
Enum type used to tag a special constructor that does not initialize the elements of the constructed ...
Definition: bbox.h:97
Vector * begin()
Returns the pointer to the first vector, min.
Definition: bbox.h:256
bool contains(const Vector &vec) const
Returns true if the point is inside or on the boundary of the bounding box.
Definition: bbox.h:332
bool is_point() const
Returns true the bounding box is a single point.
Definition: bbox.h:314
static const Size SIZE
Constant size of the bounding box.
Definition: bbox.h:87
static Size size()
Constant size of the bounding box.
Definition: bbox.h:90
Vector_struct<T, DIM> max
Elementwise maximal bounding box corner.
Definition: bbox.h:49
void clear()
Reinitializes this bounding box to the empty space.
Definition: bbox.h:112
Size largest_extent_index() const
Returns the index of the dimension in which the bounding box has its largest extent,...
Definition: bbox.h:439
bool operator<=(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is lexicographically less than or equal to rhs.
Definition: bbox.h:620
Bbox(T min_x, T max_x)
1D bounding box (interval) initialized to the new extreme corner vectors, (min_x) and (max_x).
Definition: bbox.h:159
bool is_plane() const
Returns true the bounding box is an axis-aligned plane.
Definition: bbox.h:324
Size rank() const
Returns the rank of the bounding box.
Definition: bbox.h:305
Bbox<T, 3> transform_vector(const Matrix<TT, 4, 4> &mat, const Bbox<T, 3> &bbox)
Returns the 3D bounding box transformed by a matrix.
Definition: bbox.h:843
Bbox<T, DIM> & operator-=(Bbox<T, DIM> &bbox, T value)
Shrinks bbox by a constant value at each face, i.e., value is subtracted from bbox....
Definition: bbox.h:548
Bbox(const Bbox<T, DIM> &other)=default
Default copy constructor.
Bbox<T, 3> transform_point(const Matrix<TT, 4, 4> &mat, const Bbox<T, 3> &bbox)
Returns the 3D bounding box transformed by a matrix.
Definition: bbox.h:780
Vector_struct<T, DIM> min
Elementwise minimal bounding box corner.
Definition: bbox.h:48
const Vector & operator[](Size i) const
Returns the vector min for i==0, and the vector max for i==1.
Definition: bbox.h:279
Bbox(const Bbox_struct<T, DIM> &bbox_struct)
Bounding box initialized from corresponding POD type.
Definition: bbox.h:135
void insert(const Bbox &other)
Assigns the union of this bounding box and the other bounding box to this bounding box.
Definition: bbox.h:353
bool intersects(const Bbox &other) const
Returns true if this bounding box and the other bounding box intersect in their interiors or on their...
Definition: bbox.h:343
const Vector * begin() const
Returns the pointer to the first vector, min.
Definition: bbox.h:259
T diagonal_length() const
Returns the length of the diagonal.
Definition: bbox.h:430
Bbox<T, DIM> operator-(const Bbox<T, DIM> &bbox, T value)
Returns a bounding box that is the bbox shrunk by a constant value at each face, i....
Definition: bbox.h:484
Bbox<T, DIM> operator*(const Bbox<T, DIM> &bbox, T factor)
Returns a bounding box that is a version of bbox scaled by factor, i.e., bbox.max and bbox....
Definition: bbox.h:500
Bbox<T, DIM> lerp(const Bbox<T, DIM> &bbox1, const Bbox<T, DIM> &bbox2, T t)
Returns the linear interpolation between bbox1 and bbox2, i.e., it returns (1-t) * bbox1 + t * bbox2.
Definition: bbox.h:670
@ UNINITIALIZED_TAG
Enum value used to call a special constructor that does not initialize the elements of the constructe...
Definition: bbox.h:100
Color abs(const Color &c)
Returns a color with the elementwise absolute values of the color c.
Definition: color.h:459
Color elementwise_min(const Color &lhs, const Color &rhs)
Returns elementwise min for each element in color lhs that is less than the corresponding element in ...
Definition: color.h:569
Color elementwise_max(const Color &lhs, const Color &rhs)
Returns elementwise max for each element in color lhs that is less than the corresponding element in ...
Definition: color.h:559
Assertions and compile-time assertions.
A NxM-dimensional matrix class template of fixed dimensions with supporting functions.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: example_derivatives.dox:5
Helper class to deduce properties of numeric types defined in this API.
Definition: types.h:428
Storage class for an axis-aligned N-dimensional bounding box class template of fixed dimension.
Definition: bbox.h:47
Generic storage class template for math vector representations storing DIM elements of type T.
Definition: vector.h:135
Math vector class template of fixed dimension with arithmetic operators and generic functions.