8 #ifndef IMPALGEBRA_BOUNDING_BOX_D_H
9 #define IMPALGEBRA_BOUNDING_BOX_D_H
11 #include <IMP/algebra/algebra_config.h>
13 #include "internal/utility.h"
17 IMPALGEBRA_BEGIN_NAMESPACE
29 for (
int i = 0; i < D; ++i) {
30 b_[0][i] = std::numeric_limits<double>::max();
31 b_[1][i] = -std::numeric_limits<double>::max();
48 #if defined(IMP_SWIG_WRAPPER)
54 <<
"with a variable dimension bounding box.");
62 <<
"with a variable dimension bounding box.");
64 for (
unsigned int i = 0; i < d; ++i) {
65 lb[i] = std::numeric_limits<double>::max();
66 ub[i] = -std::numeric_limits<double>::max();
76 for (
unsigned int i = 0; i < lb.get_dimension(); ++i) {
90 for (
unsigned int j = 0; j < points.size(); j++) {
91 operator+=(points[j]);
95 unsigned int get_dimension()
const {
return get_corner(0).get_dimension(); }
99 for (
unsigned int i = 0; i < get_dimension(); ++i) {
100 b_[0][i] = std::min(o.
get_corner(0)[i], get_corner(0)[i]);
101 b_[1][i] = std::max(o.
get_corner(1)[i], get_corner(1)[i]);
108 for (
unsigned int i = 0; i < get_dimension(); ++i) {
109 b_[0][i] = std::min(o[i], b_[0][i]);
110 b_[1][i] = std::max(o[i], b_[1][i]);
117 for (
unsigned int i = 0; i < get_dimension(); ++i) {
118 b_[0][i] = b_[0][i] - o;
119 b_[1][i] = b_[1][i] + o;
146 for (
unsigned int i = 0; i < get_dimension(); ++i) {
147 if (o[i] < get_corner(0)[i] || o[i] > get_corner(1)[i])
return false;
165 for (
unsigned int i = 0; i < bb.get_dimension(); ++i) {
173 return (g.get_corner(1)[0] - g.get_corner(0)[0]) *
174 (g.get_corner(1)[1] - g.get_corner(0)[1]) *
175 (g.get_corner(1)[2] - g.get_corner(0)[2]),
180 template <
unsigned int D>
182 return BoundingBoxD<D>(-get_ones_vector_d<D>(), get_ones_vector_d<D>());
193 template <
unsigned int D>
196 radius * get_ones_vector_d<D>());
212 "Dimensions of bounding boxes don't match.");
213 for (
unsigned int i = 0; i < a.get_dimension(); ++i) {
230 for (
unsigned int i = 0; i < a.get_dimension(); ++i) {
239 for (
unsigned int i = 0; i < a.get_dimension(); ++i) {
264 for (
unsigned int i = 1; i < a.get_dimension(); ++i) {
285 for (
int i = 0; i < D - 1; ++i) {
292 for (
unsigned int i = 0; i < recurse.size(); ++i) {
294 for (
int j = 0; j < D - 1; ++j) {
295 cur[j] = recurse[i][j];
308 static const IntPair edges[12] = {
309 IntPair(0, 1), IntPair(0, 2), IntPair(0, 4), IntPair(1, 3),
310 IntPair(1, 5), IntPair(2, 3), IntPair(2, 6), IntPair(3, 7),
311 IntPair(4, 5), IntPair(4, 6), IntPair(5, 7), IntPair(6, 7)};
312 static IntPairs ret(edges, edges + 12);
316 IMPALGEBRA_END_NAMESPACE
const BoundingBoxD< D > & operator+=(double o)
Grow the bounding box by o on all sizes.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
const VectorD< D > & get_corner(unsigned int i) const
For 0 return lower corner and for 1, the upper corner.
#define IMP_IF_CHECK(level)
Execute the code block if a certain level checks are on.
const BoundingBoxD< D > operator+(const BoundingBoxD< D > &o) const
Returning a bounding box containing both.
bool get_contains(const BoundingBoxD &bb) const
True if the input bounding box is completely contained within this one.
const BoundingBoxD< D > operator+(const O &o) const
Return a bounding box grown by o on all sides.
Vector< VectorD< D > > get_vertices(const BoundingBoxD< D > &bb)
Return a list of the 2^D bounding points for the bounding box.
double get_maximum_length(const BoundingBoxD< D > &a)
Return the maximum axis aligned extent.
double get_volume(const Cone3D &g)
IntPairs get_edges(const BoundingBoxD< 3 > &)
Return the edges of the box as indices into the vertices list.
BoundingBoxD< D > get_union(BoundingBoxD< D > a, const BoundingBoxD< D > &b)
Return the union bounding box.
BoundingBoxD< D > get_cube_d(double radius)
Cube with radius of length radius.
Exception definitions and assertions.
BoundingBoxD(unsigned int d)
Create an empty bounding box.
const BoundingBoxD< D > & operator+=(const BoundingBoxD< D > &o)
Extend the current bounding box to include the other.
VectorD< D > get_ones_vector_kd(unsigned int Di, double v=1)
Return a vector of ones (or another constant)
BoundingBoxD< D > get_intersection(const BoundingBoxD< D > &a, const BoundingBoxD< D > &b)
Return the intersecting bounding box.
const BoundingBoxD< D > & operator+=(const VectorD< D > &o)
Extend the current bounding box to include the point.
bool get_interiors_intersect(const BoundingBoxD< D > &a, const BoundingBoxD< D > &b)
Return true if they intersect.
A Cartesian vector in D-dimensions.
BoundingBoxD()
Create an empty bounding box.
#define IMP_UNUSED(variable)
#define IMP_VOLUME_GEOMETRY_METHODS_D(Name, name, area, volume, bounding_box)
Implement the needed namespace methods for a geometry type.
BoundingBoxD<-1 > get_unit_bounding_box_kd(unsigned int d)
Box with radius one.
BoundingBoxD<-1 > get_cube_kd(unsigned int d, double radius)
Cube with radius of length side.
An axis-aligned bounding box.
BoundingBoxD(const Vector< VectorD< D > > &points)
Creating a bounding box from a set of points.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
BoundingBoxD< D > get_unit_bounding_box_d()
Box with radius one.
bool get_contains(const VectorD< D > &o) const
True if the point o is contained within this bounding box.
#define IMP_NOT_IMPLEMENTED
Use this to mark that the method is not implemented yet.
BoundingBoxD(const VectorD< D > &v)
Creating a bounding box containing one point.
Various important macros for implementing geometry.
BoundingBoxD(const VectorD< D > &lb, const VectorD< D > &ub)
Make from the lower and upper corners.