// static Box3f Box3f::united( const Box3f& b0, const Box3f& b1 ) { Vector3f unitedMin = libcgt::core::math::minimum( b0.leftBottomBack(), b1.leftBottomBack() ); Vector3f unitedMax = libcgt::core::math::maximum( b0.rightTopFront(), b1.rightTopFront() ); return{ unitedMin, unitedMax - unitedMin }; }
// static bool Box3f::intersect( const Box3f& b0, const Box3f& b1, Box3f& intersection ) { Vector3f minimum = libcgt::core::math::maximum( b0.leftBottomBack(), b1.leftBottomBack() ); Vector3f maximum = libcgt::core::math::minimum( b0.rightTopFront(), b1.rightTopFront() ); if( minimum.x < maximum.x && minimum.y < maximum.y && minimum.z < maximum.z ) { intersection.origin = minimum; intersection.size = maximum - minimum; return true; } return false; }