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();
39 <<
"with a variable dim bounding box.");
46 <<
"with a variable dim bounding box.");
48 for (
unsigned int i = 0; i < d; ++i) {
49 lb[i] = std::numeric_limits<double>::max();
50 ub[i] = -std::numeric_limits<double>::max();
60 for (
unsigned int i = 0; i < lb.get_dimension(); ++i) {
74 for (
unsigned int j = 0; j < points.size(); j++) {
75 operator+=(points[j]);
79 unsigned int get_dimension()
const {
return get_corner(0).get_dimension(); }
83 for (
unsigned int i = 0; i < get_dimension(); ++i) {
84 b_[0][i] = std::min(o.
get_corner(0)[i], get_corner(0)[i]);
85 b_[1][i] = std::max(o.
get_corner(1)[i], get_corner(1)[i]);
92 for (
unsigned int i = 0; i < get_dimension(); ++i) {
93 b_[0][i] = std::min(o[i], b_[0][i]);
94 b_[1][i] = std::max(o[i], b_[1][i]);
101 for (
unsigned int i = 0; i < get_dimension(); ++i) {
102 b_[0][i] = b_[0][i] - o;
103 b_[1][i] = b_[1][i] + o;
130 for (
unsigned int i = 0; i < get_dimension(); ++i) {
131 if (o[i] < get_corner(0)[i] || o[i] > get_corner(1)[i])
return false;
149 for (
unsigned int i = 0; i < bb.get_dimension(); ++i) {
157 return (g.get_corner(1)[0] - g.get_corner(0)[0]) *
158 (g.get_corner(1)[1] - g.get_corner(0)[1]) *
159 (g.get_corner(1)[2] - g.get_corner(0)[2]),
164 template <
unsigned int D>
166 return BoundingBoxD<D>(-get_ones_vector_d<D>(), get_ones_vector_d<D>());
177 template <
unsigned int D>
180 radius * get_ones_vector_d<D>());
196 "Dimensions of bounding boxes don't match.");
197 for (
unsigned int i = 0; i < a.get_dimension(); ++i) {
212 for (
unsigned int i = 0; i < a.get_dimension(); ++i) {
221 for (
unsigned int i = 0; i < a.get_dimension(); ++i) {
246 for (
unsigned int i = 1; i < a.get_dimension(); ++i) {
267 for (
int i = 0; i < D - 1; ++i) {
274 for (
unsigned int i = 0; i < recurse.size(); ++i) {
276 for (
int j = 0; j < D - 1; ++j) {
277 cur[j] = recurse[i][j];
290 static const IntPair edges[12] = {
291 IntPair(0, 1), IntPair(0, 2), IntPair(0, 4), IntPair(1, 3),
292 IntPair(1, 5), IntPair(2, 3), IntPair(2, 6), IntPair(3, 7),
293 IntPair(4, 5), IntPair(4, 6), IntPair(5, 7), IntPair(6, 7)};
294 static IntPairs ret(edges, edges + 12);
298 IMPALGEBRA_END_NAMESPACE
const BoundingBoxD< D > & operator+=(double o)
#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 1 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 contained within this bounding box.
const BoundingBoxD< D > operator+(const O &o) const
Return a bounding box grown by o on all sides.
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(const base::Vector< VectorD< D > > &points)
Creating a bounding box from a set of points.
BoundingBoxD<-1 > get_cube_kd(unsigned int d, double radius)
Cube with radius of length side.
An axis-aligned bounding box.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
base::Vector< VectorD< D > > get_vertices(const BoundingBoxD< D > &bb)
Return a list of the 8 bounding points for the bounding box.
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.