lsst.sphgeom
19.0.0-3-gc70e9ed+1
|
Go to the documentation of this file.
23 #ifndef LSST_SPHGEOM_BOX3D_H_
24 #define LSST_SPHGEOM_BOX3D_H_
45 static Box3d empty() {
50 return Box3d(Interval1d::full(),
88 _intervals[0] =
Interval1d(v.x()).dilatedBy(w);
89 _intervals[1] =
Interval1d(v.y()).dilatedBy(h);
90 _intervals[2] =
Interval1d(v.z()).dilatedBy(d);
103 _enforceInvariants();
108 return _intervals[0] == b._intervals[0] &&
109 _intervals[1] == b._intervals[1] &&
110 _intervals[2] == b._intervals[2];
113 bool operator!=(
Box3d const & b)
const {
return !(*
this == b); }
118 bool operator!=(
Vector3d const & v)
const {
return !(*
this == v); }
123 Interval1d const & x()
const {
return _intervals[0]; }
124 Interval1d
const & y()
const {
return _intervals[1]; }
125 Interval1d
const & z()
const {
return _intervals[2]; }
214 _intervals[0].
clipTo(b.x());
215 _intervals[1].
clipTo(b.y());
216 _intervals[2].
clipTo(b.z());
217 _enforceInvariants();
222 _intervals[0].
clipTo(b.x());
223 _intervals[1].
clipTo(b.y());
224 _intervals[2].
clipTo(b.z());
225 _enforceInvariants();
233 return Box3d(*this).clipTo(b);
237 return Box3d(*this).clipTo(b);
262 return Box3d(*this).expandTo(b);
266 return Box3d(*this).expandTo(b);
277 Box3d dilatedBy(
double r)
const {
return Box3d(*this).dilateBy(r); }
290 _enforceInvariants();
293 Box3d dilatedBy(
double w,
double h,
double d)
const {
294 return Box3d(*this).dilateBy(w, h, d);
297 Box3d erodedBy(
double r)
const {
return dilatedBy(-r); }
298 Box3d & erodeBy(
double w,
double h,
double d) {
301 Box3d erodedBy(
double w,
double h,
double d)
const {
302 return dilatedBy(-w, -h, -d);
314 return ((xr & yr & zr) & (CONTAINS | WITHIN)) |
315 ((xr | yr | zr) & DISJOINT);
320 void _enforceInvariants() {
324 _intervals[0] = Interval1d();
325 _intervals[1] = Interval1d();
326 _intervals[2] = Interval1d();
330 Interval1d _intervals[3];
333 std::ostream & operator<<(std::ostream &, Box3d
const &);
337 #endif // LSST_SPHGEOM_BOX3D_H_
Box3d(Vector3d const &v)
This constructor creates a box containing a single point.
Definition: Box3d.h:66
Box3d & dilateBy(double r)
Definition: Box3d.h:276
Interval & dilateBy(Scalar x)
Definition: Interval.h:230
bool intersects(Scalar x) const
Definition: Interval.h:130
Box3d expandedTo(Vector3d const &b) const
Definition: Box3d.h:261
bool contains(Vector3d const &b) const
Definition: Box3d.h:158
Definition: Interval1d.h:39
Vector3d getCenter() const
Definition: Box3d.h:139
double getHeight() const
Definition: Box3d.h:149
This file defines a class for representing intervals of ℝ.
Box3d()
This constructor creates an empty 3D box.
Definition: Box3d.h:63
bool isFull() const
isFull returns true if this interval = ℝ.
Definition: Interval1d.h:62
std::bitset< 3 > Relationship
Relationship describes how two sets are related.
Definition: Relationship.h:35
static Box3d aroundUnitSphere()
aroundUnitSphere returns a minimal Box3d containing the unit sphere.
Definition: Box3d.h:56
Box3d(Vector3d const &v, double w, double h, double d)
Definition: Box3d.h:86
Box3d & clipTo(Vector3d const &b)
Definition: Box3d.h:213
This file declares a class for representing vectors in ℝ³.
Scalar getSize() const
Definition: Interval.h:93
Box3d & expandTo(Vector3d const &b)
Definition: Box3d.h:243
Interval1d operator()(int i) const
The function call operator returns the i-th interval of this box.
Definition: Box3d.h:121
bool isWithin(Vector3d const &b) const
Definition: Box3d.h:198
Box3d & dilateBy(double w, double h, double d)
Definition: Box3d.h:286
This file provides a type alias for describing set relationships.
Relationship relate(Scalar x) const
Definition: Interval.h:249
double getWidth() const
Definition: Box3d.h:145
double getDepth() const
Definition: Box3d.h:153
bool isFull() const
isFull returns true if this box contains all points in ℝ³.
Definition: Box3d.h:133
Box3d(Interval1d const &x, Interval1d const &y, Interval1d const &z)
Definition: Box3d.h:96
bool operator==(Vector3d const &v) const
A box is equal to a point if it contains only that point.
Definition: Box3d.h:116
bool operator==(Box3d const &b) const
Two 3D boxes are equal if they contain the same points.
Definition: Box3d.h:107
Vector3d is a vector in ℝ³ with components stored in double precision.
Definition: Vector3d.h:44
Box3d(Vector3d const &v1, Vector3d const &v2)
Definition: Box3d.h:76
Box3d clippedTo(Vector3d const &b) const
Definition: Box3d.h:232
bool contains(Scalar x) const
Definition: Interval.h:98
Interval & expandTo(Scalar x)
Definition: Interval.h:192
bool isEmpty() const
isEmpty returns true if this interval does not contain any points.
Definition: Interval.h:83
bool isWithin(Scalar x) const
Definition: Interval.h:140
bool intersects(Vector3d const &b) const
Definition: Box3d.h:182
bool isEmpty() const
isEmpty returns true if this box does not contain any points.
Definition: Box3d.h:128
bool isDisjointFrom(Vector3d const &b) const
Definition: Box3d.h:174
Interval & clipTo(Scalar x)
Definition: Interval.h:159