8 #ifndef IMPALGEBRA_BOUNDING_BOX_D_H
9 #define IMPALGEBRA_BOUNDING_BOX_D_H
11 #include <IMP/algebra/algebra_config.h>
16 IMPALGEBRA_BEGIN_NAMESPACE
30 for (
int i=0; i< D; ++i) {
31 b_[0][i]= std::numeric_limits<double>::max();
32 b_[1][i]=-std::numeric_limits<double>::max();
40 <<
"with a variable dim bounding box.");
47 <<
"with a variable dim bounding box.");
49 for (
unsigned int i=0; i< d; ++i) {
50 lb[i]= std::numeric_limits<double>::max();
51 ub[i]=-std::numeric_limits<double>::max();
62 for (
unsigned int i=0; i< lb.get_dimension(); ++i) {
64 "Invalid bounding box");
76 for(
unsigned int j=0;j<points.size();j++) {
77 operator+=(points[j]);
81 unsigned int get_dimension()
const {
82 return get_corner(0).get_dimension();
87 for (
unsigned int i=0; i< get_dimension(); ++i) {
88 b_[0][i]= std::min(o.
get_corner(0)[i], get_corner(0)[i]);
89 b_[1][i]= std::max(o.
get_corner(1)[i], get_corner(1)[i]);
96 for (
unsigned int i=0; i< get_dimension(); ++i) {
97 b_[0][i]= std::min(o[i], b_[0][i]);
98 b_[1][i]= std::max(o[i], b_[1][i]);
105 for (
unsigned int i=0; i< get_dimension(); ++i) {
106 b_[0][i]= b_[0][i]-o;
107 b_[1][i]= b_[1][i]+o;
134 for (
unsigned int i=0; i< get_dimension(); ++i) {
135 if (o[i] < get_corner(0)[i]
136 || o[i] > get_corner(1)[i])
return false;
154 for (
unsigned int i=0; i< bb.get_dimension(); ++i) {
162 return (g.get_corner(1)[0]- g.get_corner(0)[0])
163 *(g.get_corner(1)[1]- g.get_corner(0)[1])
164 *(g.get_corner(1)[2]- g.get_corner(0)[2]),
170 template <
unsigned int D>
172 return BoundingBoxD<D>(-get_ones_vector_d<D>(), get_ones_vector_d<D>());
183 template <
unsigned int D>
186 radius*get_ones_vector_d<D>());
203 "Dimensions of bounding boxes don't match.");
204 for (
unsigned int i=0; i< a.get_dimension(); ++i) {
219 for (
unsigned int i=0; i< a.get_dimension(); ++i) {
225 for (
unsigned int i=0; i< a.get_dimension(); ++i) {
250 for (
unsigned int i=1; i< a.get_dimension(); ++i) {
262 for (
unsigned int i=0; i< 2; ++i) {
263 for (
unsigned int j=0; j< 2; ++j) {
264 for (
unsigned int k=0; k< 2; ++k) {
277 static const IntPair edges[12]={IntPair(0,1), IntPair(0,2), IntPair(0,4),
278 IntPair(1,3), IntPair(1,5),
279 IntPair(2,3), IntPair(2,6),
281 IntPair(4,5), IntPair(4,6),
284 static IntPairs ret(edges, edges+12);
288 IMPALGEBRA_END_NAMESPACE