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++) {
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++)
309 rank += (
min[i] <
max[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++)
423 vol *= base::max MI_PREVENT_MACRO_EXPAND ( T(0), diag[i]);
444 for(
Size i = 1; i < DIM; i++) {
445 if (maxval < diag[i]) {
467 template <
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;
483 template <
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;
499 template <
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;
515 template <
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;
532 template <
typename T, Size DIM>
536 for(
Size i = 0; i < DIM; i++) {
537 (bbox.
min)[i] -= value;
538 (bbox.
max)[i] += value;
547 template <
typename T, Size DIM>
551 for(
Size i = 0; i < DIM; i++) {
552 (bbox.
min)[i] += value;
553 (bbox.
max)[i] -= value;
561 template <
typename T, Size DIM>
565 for(
Size i = 0; i < DIM; i++) {
566 (bbox.
min)[i] *= factor;
567 (bbox.
max)[i] *= factor;
575 template <
typename T, Size DIM>
580 for(
Size i = 0; i < DIM; i++) {
581 (bbox.
min)[i] /= divisor;
582 (bbox.
max)[i] /= divisor;
588 template <
typename T, Size DIM>
591 return (lhs.
min) == (rhs.
min) && (lhs.
max) == (rhs.
max);
595 template <
typename T, Size DIM>
598 return (lhs.
min) != (rhs.
min) || (lhs.
max) != (rhs.
max);
604 template <
typename T, Size DIM>
605 inline bool operator< ( const Bbox<T,DIM> & lhs,
const Bbox<T,DIM> & rhs)
607 for(
Size i(0u); i < DIM; ++i) {
608 if( (lhs.min)[i] < (rhs.min)[i])
610 if( (lhs.min)[i] > (rhs.min)[i])
619 template <
typename T, Size DIM>
620 inline bool operator<=( const Bbox<T,DIM>& lhs,
const Bbox<T,DIM>& rhs)
622 for(
Size i(0u); i < DIM; ++i) {
623 if( (lhs.min)[i] < (rhs.min)[i])
625 if( (lhs.min)[i] > (rhs.min)[i])
634 template <
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])
649 template <
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])
669 template <
typename T, Size DIM>
684 template <
typename T, Size DIM>
690 for(
Size i = 0; i < DIM; i++) {
693 if (result.
max[i] < result.
min[i]) {
714 template <
typename TT,
typename T>
715 Bbox<T,3>
transform_point(
const Matrix<TT,4,4>& mat,
const Bbox<T,3>& bbox);
726 template <
typename TT,
typename T>
727 Bbox<T,3>
transform_vector(
const Matrix<TT,4,4>& mat,
const Bbox<T,3>& bbox);
733 #ifndef MI_FOR_DOXYGEN_ONLY
735 template <
typename T, Size DIM>
736 template <
typename InputIterator>
739 for( ; first != last; ++first)
743 template <
typename T, Size DIM>
744 template <
typename InputIterator>
748 insert( first, last);
751 template <
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;
777 #endif // MI_FOR_DOXYGEN_ONLY
779 template <
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) {
842 template <
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;
874 #endif // MI_MATH_BBOX_H