10 #ifndef MI_MATH_BBOX_H
11 #define MI_MATH_BBOX_H
45 template <
typename T, Size DIM>
72 template <
typename T, Size DIM>
114 for(
Size i = 0; i < DIM; i++) {
131 #if (__cplusplus >= 201103L)
209 template <
typename InputIterator>
216 template <
typename T2>
225 template <
typename T2>
292 for(
Size i = 0; i < DIM; i++) {
310 for(
Size i = 0; i < DIM; i++)
311 rank += (
min[i] <
max[i]);
336 for(
Size i = 0; i < DIM; i++) {
337 if( vec[i] <
min[i] || vec[i] >
max[i])
347 for(
Size i = 0; i < DIM; i++) {
375 template <
typename InputIterator>
424 for(
Size i = 1; i < DIM; i++)
425 vol *= base::max MI_PREVENT_MACRO_EXPAND ( T(0), diag[i]);
446 for(
Size i = 1; i < DIM; i++) {
447 if (maxval < diag[i]) {
469 template <
typename T, Size DIM>
474 for(
Size i = 0; i < DIM; i++) {
475 (result.min)[i] = (bbox.
min)[i] - value;
476 (result.max)[i] = (bbox.
max)[i] + value;
485 template <
typename T, Size DIM>
490 for(
Size i = 0; i < DIM; i++) {
491 (result.min)[i] = (bbox.
min)[i] + value;
492 (result.max)[i] = (bbox.
max)[i] - value;
501 template <
typename T, Size DIM>
506 for(
Size i = 0; i < DIM; i++) {
507 (result.min)[i] = (bbox.
min)[i] * factor;
508 (result.max)[i] = (bbox.
max)[i] * factor;
517 template <
typename T, Size DIM>
523 for(
Size i = 0; i < DIM; i++) {
524 (result.
min)[i] = (bbox.
min)[i] / divisor;
525 (result.
max)[i] = (bbox.
max)[i] / divisor;
534 template <
typename T, Size DIM>
538 for(
Size i = 0; i < DIM; i++) {
539 (bbox.
min)[i] -= value;
540 (bbox.
max)[i] += value;
549 template <
typename T, Size DIM>
553 for(
Size i = 0; i < DIM; i++) {
554 (bbox.
min)[i] += value;
555 (bbox.
max)[i] -= value;
563 template <
typename T, Size DIM>
567 for(
Size i = 0; i < DIM; i++) {
568 (bbox.
min)[i] *= factor;
569 (bbox.
max)[i] *= factor;
577 template <
typename T, Size DIM>
582 for(
Size i = 0; i < DIM; i++) {
583 (bbox.
min)[i] /= divisor;
584 (bbox.
max)[i] /= divisor;
590 template <
typename T, Size DIM>
593 return (lhs.
min) == (rhs.
min) && (lhs.
max) == (rhs.
max);
597 template <
typename T, Size DIM>
600 return (lhs.
min) != (rhs.
min) || (lhs.
max) != (rhs.
max);
606 template <
typename T, Size DIM>
607 inline bool operator< ( const Bbox<T,DIM> & lhs,
const Bbox<T,DIM> & rhs)
609 for(
Size i(0u); i < DIM; ++i) {
610 if( (lhs.min)[i] < (rhs.min)[i])
612 if( (lhs.min)[i] > (rhs.min)[i])
621 template <
typename T, Size DIM>
622 inline bool operator<=( const Bbox<T,DIM>& lhs,
const Bbox<T,DIM>& rhs)
624 for(
Size i(0u); i < DIM; ++i) {
625 if( (lhs.min)[i] < (rhs.min)[i])
627 if( (lhs.min)[i] > (rhs.min)[i])
636 template <
typename T, Size DIM>
639 for(
Size i(0u); i < DIM; ++i) {
640 if( (lhs.
min)[i] > (rhs.
min)[i])
642 if( (lhs.
min)[i] < (rhs.
min)[i])
651 template <
typename T, Size DIM>
654 for(
Size i(0u); i < DIM; ++i) {
655 if( (lhs.
min)[i] > (rhs.
min)[i])
657 if( (lhs.
min)[i] < (rhs.
min)[i])
671 template <
typename T, Size DIM>
686 template <
typename T, Size DIM>
692 for(
Size i = 0; i < DIM; i++) {
695 if (result.
max[i] < result.
min[i]) {
716 template <
typename TT,
typename T>
717 Bbox<T,3>
transform_point(
const Matrix<TT,4,4>& mat,
const Bbox<T,3>& bbox);
728 template <
typename TT,
typename T>
729 Bbox<T,3>
transform_vector(
const Matrix<TT,4,4>& mat,
const Bbox<T,3>& bbox);
735 #ifndef MI_FOR_DOXYGEN_ONLY
737 template <
typename T, Size DIM>
738 template <
typename InputIterator>
741 for( ; first != last; ++first)
745 template <
typename T, Size DIM>
746 template <
typename InputIterator>
750 insert( first, last);
753 template <
typename T, Size DIM>
767 for(
Size i = 0; i < DIM; i++)
772 for(
Size i = 0; i < DIM; i++)
774 const T margin = max_dist * eps;
779 #endif // MI_FOR_DOXYGEN_ONLY
781 template <
typename TT,
typename T>
796 corners[0].x += T(mat.wx);
797 corners[0].y += T(mat.wy);
798 corners[0].z += T(mat.wz);
805 corners[1] = corners[0] + dz;
806 corners[2] = corners[0] + dy;
807 corners[3] = corners[0] + dy + dz;
808 corners[4] = corners[0] + dx;
809 corners[5] = corners[0] + dx + dz;
810 corners[6] = corners[0] + dx + dy;
811 corners[7] = corners[0] + dx + dy + dz;
817 T wx = T( mat.xw * ((bbox.
max).x - (bbox.
min).x));
818 T wy = T( mat.yw * ((bbox.
max).y - (bbox.
min).y));
819 T wz = T( mat.zw * ((bbox.
max).z - (bbox.
min).z));
822 w[0] = T(mat.xw * (bbox.
min).x + mat.yw * (bbox.
min).y + mat.zw * (bbox.
min).z + mat.ww);
825 w[3] = w[0] + wy + wz;
827 w[5] = w[0] + wx + wz;
828 w[6] = w[0] + wx + wy;
829 w[7] = w[0] + wx + wy + wz;
832 for(
unsigned int i=0; i<8; ++i) {
833 if( w[i]!=0 && w[i]!=1) {
844 template <
typename TT,
typename T>
858 corners[1] = corners[0] + dz;
859 corners[2] = corners[0] + dy;
860 corners[3] = corners[0] + dy + dz;
861 corners[4] = corners[0] + dx;
862 corners[5] = corners[0] + dx + dz;
863 corners[6] = corners[0] + dx + dy;
864 corners[7] = corners[0] + dx + dy + dz;
876 #endif // MI_MATH_BBOX_H