30#ifndef LSST_SPHGEOM_BOX3D_H_
31#define LSST_SPHGEOM_BOX3D_H_
52 static Box3d empty() {
57 return Box3d(Interval1d::full(),
95 _intervals[0] =
Interval1d(v.x()).dilatedBy(w);
96 _intervals[1] =
Interval1d(v.y()).dilatedBy(h);
97 _intervals[2] =
Interval1d(v.z()).dilatedBy(d);
110 _enforceInvariants();
115 return _intervals[0] == b._intervals[0] &&
116 _intervals[1] == b._intervals[1] &&
117 _intervals[2] == b._intervals[2];
120 bool operator!=(
Box3d const & b)
const {
return !(*
this == b); }
125 bool operator!=(
Vector3d const & v)
const {
return !(*
this == v); }
130 Interval1d const & x()
const {
return _intervals[0]; }
131 Interval1d
const & y()
const {
return _intervals[1]; }
132 Interval1d
const & z()
const {
return _intervals[2]; }
177 bool contains(
double x_,
double y_,
double z_)
const {
225 _intervals[0].
clipTo(b.x());
226 _intervals[1].
clipTo(b.y());
227 _intervals[2].
clipTo(b.z());
228 _enforceInvariants();
233 _intervals[0].
clipTo(b.x());
234 _intervals[1].
clipTo(b.y());
235 _intervals[2].
clipTo(b.z());
236 _enforceInvariants();
301 _enforceInvariants();
304 Box3d dilatedBy(
double w,
double h,
double d)
const {
308 Box3d erodedBy(
double r)
const {
return dilatedBy(-r); }
309 Box3d & erodeBy(
double w,
double h,
double d) {
312 Box3d erodedBy(
double w,
double h,
double d)
const {
313 return dilatedBy(-w, -h, -d);
325 return ((xr & yr & zr) & (CONTAINS | WITHIN)) |
326 ((xr | yr | zr) & DISJOINT);
331 void _enforceInvariants() {
335 _intervals[0] = Interval1d();
336 _intervals[1] = Interval1d();
337 _intervals[2] = Interval1d();
341 Interval1d _intervals[3];
344std::ostream & operator<<(std::ostream &, Box3d
const &);
This file defines a class for representing intervals of ℝ.
This file declares a class for representing vectors in ℝ³.
double getHeight() const
Definition Box3d.h:156
bool isEmpty() const
isEmpty returns true if this box does not contain any points.
Definition Box3d.h:135
bool isFull() const
isFull returns true if this box contains all points in ℝ³.
Definition Box3d.h:140
bool intersects(Vector3d const &b) const
Definition Box3d.h:193
double getDepth() const
Definition Box3d.h:160
bool operator==(Box3d const &b) const
Two 3D boxes are equal if they contain the same points.
Definition Box3d.h:114
Box3d(Vector3d const &v1, Vector3d const &v2)
Definition Box3d.h:83
Box3d & dilateBy(double r)
Definition Box3d.h:287
Box3d(Vector3d const &v, double w, double h, double d)
Definition Box3d.h:93
Box3d & dilateBy(double w, double h, double d)
Definition Box3d.h:297
Box3d & expandTo(Vector3d const &b)
Definition Box3d.h:254
bool isDisjointFrom(Vector3d const &b) const
Definition Box3d.h:185
Interval1d operator()(int i) const
The function call operator returns the i-th interval of this box.
Definition Box3d.h:128
bool isWithin(Vector3d const &b) const
Definition Box3d.h:209
Box3d & clipTo(Vector3d const &b)
Definition Box3d.h:224
Box3d()
This constructor creates an empty 3D box.
Definition Box3d.h:70
bool operator==(Vector3d const &v) const
A box is equal to a point if it contains only that point.
Definition Box3d.h:123
Box3d expandedTo(Vector3d const &b) const
Definition Box3d.h:272
Box3d(Vector3d const &v)
This constructor creates a box containing a single point.
Definition Box3d.h:73
double getWidth() const
Definition Box3d.h:152
Box3d clippedTo(Vector3d const &b) const
Definition Box3d.h:243
static Box3d aroundUnitSphere()
aroundUnitSphere returns a minimal Box3d containing the unit sphere.
Definition Box3d.h:63
Vector3d getCenter() const
Definition Box3d.h:146
bool contains(Vector3d const &b) const
Definition Box3d.h:165
Box3d(Interval1d const &x, Interval1d const &y, Interval1d const &z)
Definition Box3d.h:103
Definition Interval1d.h:47
bool isFull() const
isFull returns true if this interval = ℝ.
Definition Interval1d.h:70
bool isWithin(Scalar x) const
Definition Interval.h:147
Interval & dilateBy(Scalar x)
Definition Interval.h:237
Scalar getSize() const
Definition Interval.h:100
Interval & clipTo(Scalar x)
Definition Interval.h:166
bool isEmpty() const
isEmpty returns true if this interval does not contain any points.
Definition Interval.h:90
Relationship relate(Scalar x) const
Definition Interval.h:256
bool intersects(Scalar x) const
Definition Interval.h:137
Interval & expandTo(Scalar x)
Definition Interval.h:199
bool contains(Scalar x) const
Definition Interval.h:105
Vector3d is a vector in ℝ³ with components stored in double precision.
Definition Vector3d.h:51
std::bitset< 3 > Relationship
Relationship describes how two sets are related.
Definition Relationship.h:42
This file provides a type alias for describing set relationships.