LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Public Member Functions | Static Public Member Functions | List of all members
lsst::sphgeom::Box3d Class Reference

Box3d represents a box in ℝ³. More...

#include <Box3d.h>

Public Member Functions

 Box3d ()
 This constructor creates an empty 3D box. More...
 
 Box3d (Vector3d const &v)
 This constructor creates a box containing a single point. More...
 
 Box3d (Vector3d const &v1, Vector3d const &v2)
 This constructor creates a box spanning the intervals [v1.x(), v2.x()], [v1.y(), v2.y()], and [v1.z(), v2.z()]. More...
 
 Box3d (Vector3d const &v, double w, double h, double d)
 This constructor creates a box with center v, half-width w, half-height h, and half-depth d. More...
 
 Box3d (Interval1d const &x, Interval1d const &y, Interval1d const &z)
 This constructor creates a box spanning the given x, y, and z intervals. More...
 
bool operator== (Box3d const &b) const
 Two 3D boxes are equal if they contain the same points. More...
 
bool operator!= (Box3d const &b) const
 
bool operator== (Vector3d const &v) const
 A box is equal to a point if it contains only that point. More...
 
bool operator!= (Vector3d const &v) const
 
Interval1d operator() (int i) const
 The function call operator returns the i-th interval of this box. More...
 
Interval1d const & x () const
 
Interval1d const & y () const
 
Interval1d const & z () const
 
bool isEmpty () const
 isEmpty returns true if this box does not contain any points. More...
 
bool isFull () const
 isFull returns true if this box contains all points in ℝ³. More...
 
Vector3d getCenter () const
 getCenter returns the center of this box. More...
 
double getWidth () const
 getWidth returns the width (x-axis extent) of this box. More...
 
double getHeight () const
 getHeight returns the height (y-axis extent) of this box. More...
 
double getDepth () const
 getDepth returns the depth (z-axis extent) of this box. More...
 
Box3ddilateBy (double r)
 dilateBy minimally expands or shrinks this Box to include or remove all points within distance |r| of its boundary. More...
 
Box3d dilatedBy (double r) const
 
Box3ddilateBy (double w, double h, double d)
 dilateBy morphologically dilates or erodes the x, y, and z intervals of this box by w, h, and d. More...
 
Box3d dilatedBy (double w, double h, double d) const
 
Box3derodeBy (double r)
 
Box3d erodedBy (double r) const
 
Box3derodeBy (double w, double h, double d)
 
Box3d erodedBy (double w, double h, double d) const
 
Relationship relate (Vector3d const &v) const
 
Relationship relate (Box3d const &b) const
 
bool contains (Vector3d const &b) const
 
bool contains (Box3d const &b) const
 
bool contains (double x_, double y_, double z_) const
 
bool isDisjointFrom (Vector3d const &b) const
 
bool isDisjointFrom (Box3d const &b) const
 
bool intersects (Vector3d const &b) const
 
bool intersects (Box3d const &b) const
 
bool isWithin (Vector3d const &b) const
 
bool isWithin (Box3d const &b) const
 
Box3dclipTo (Vector3d const &b)
 
Box3dclipTo (Box3d const &b)
 
Box3d clippedTo (Vector3d const &b) const
 
Box3d clippedTo (Box3d const &b) const
 
Box3dexpandTo (Vector3d const &b)
 
Box3dexpandTo (Box3d const &b)
 
Box3d expandedTo (Vector3d const &b) const
 
Box3d expandedTo (Box3d const &b) const
 

Static Public Member Functions

static Box3d empty ()
 
static Box3d full ()
 
static Box3d aroundUnitSphere ()
 aroundUnitSphere returns a minimal Box3d containing the unit sphere. More...
 

Detailed Description

Box3d represents a box in ℝ³.

It is the Cartesian product of three intervals of ℝ.

Definition at line 42 of file Box3d.h.

Constructor & Destructor Documentation

◆ Box3d() [1/5]

lsst::sphgeom::Box3d::Box3d ( )
inline

This constructor creates an empty 3D box.

Definition at line 63 of file Box3d.h.

63 {}

◆ Box3d() [2/5]

lsst::sphgeom::Box3d::Box3d ( Vector3d const &  v)
inlineexplicit

This constructor creates a box containing a single point.

Definition at line 66 of file Box3d.h.

67  {
68  _intervals[0] = Interval1d(v.x());
69  _intervals[1] = Interval1d(v.y());
70  _intervals[2] = Interval1d(v.z());
71  _enforceInvariants();
72  }

◆ Box3d() [3/5]

lsst::sphgeom::Box3d::Box3d ( Vector3d const &  v1,
Vector3d const &  v2 
)
inline

This constructor creates a box spanning the intervals [v1.x(), v2.x()], [v1.y(), v2.y()], and [v1.z(), v2.z()].

Definition at line 76 of file Box3d.h.

77  {
78  _intervals[0] = Interval1d(v1.x(), v2.x());
79  _intervals[1] = Interval1d(v1.y(), v2.y());
80  _intervals[2] = Interval1d(v1.z(), v2.z());
81  _enforceInvariants();
82  }

◆ Box3d() [4/5]

lsst::sphgeom::Box3d::Box3d ( Vector3d const &  v,
double  w,
double  h,
double  d 
)
inline

This constructor creates a box with center v, half-width w, half-height h, and half-depth d.

Definition at line 86 of file Box3d.h.

87  {
88  _intervals[0] = Interval1d(v.x()).dilatedBy(w);
89  _intervals[1] = Interval1d(v.y()).dilatedBy(h);
90  _intervals[2] = Interval1d(v.z()).dilatedBy(d);
91  _enforceInvariants();
92  }
Derived dilatedBy(Scalar x) const
Definition: Interval.h:239
double w
Definition: CoaddPsf.cc:69

◆ Box3d() [5/5]

lsst::sphgeom::Box3d::Box3d ( Interval1d const &  x,
Interval1d const &  y,
Interval1d const &  z 
)
inline

This constructor creates a box spanning the given x, y, and z intervals.

Definition at line 96 of file Box3d.h.

99  {
100  _intervals[0] = Interval1d(x);
101  _intervals[1] = Interval1d(y);
102  _intervals[2] = Interval1d(z);
103  _enforceInvariants();
104  }
Interval1d const & z() const
Definition: Box3d.h:125
Interval1d const & x() const
Definition: Box3d.h:123
Interval1d const & y() const
Definition: Box3d.h:124

Member Function Documentation

◆ aroundUnitSphere()

static Box3d lsst::sphgeom::Box3d::aroundUnitSphere ( )
inlinestatic

aroundUnitSphere returns a minimal Box3d containing the unit sphere.

Definition at line 56 of file Box3d.h.

56  {
57  return Box3d(Interval1d(-1.0, 1.0),
58  Interval1d(-1.0, 1.0),
59  Interval1d(-1.0, 1.0));
60  }
Box3d()
This constructor creates an empty 3D box.
Definition: Box3d.h:63

◆ clippedTo() [1/2]

Box3d lsst::sphgeom::Box3d::clippedTo ( Box3d const &  b) const
inline

clippedTo returns the intersection of this box and b.

Definition at line 240 of file Box3d.h.

240  {
241  return Box3d(*this).clipTo(b);
242  }
table::Key< int > b

◆ clippedTo() [2/2]

Box3d lsst::sphgeom::Box3d::clippedTo ( Vector3d const &  b) const
inline

clippedTo returns the intersection of this box and b.

Definition at line 236 of file Box3d.h.

236  {
237  return Box3d(*this).clipTo(b);
238  }

◆ clipTo() [1/2]

Box3d& lsst::sphgeom::Box3d::clipTo ( Box3d const &  b)
inline

clipTo sets this box to the intersection of this box and b.

Definition at line 225 of file Box3d.h.

225  {
226  _intervals[0].clipTo(b.x());
227  _intervals[1].clipTo(b.y());
228  _intervals[2].clipTo(b.z());
229  _enforceInvariants();
230  return *this;
231  }
Interval & clipTo(Scalar x)
Definition: Interval.h:159

◆ clipTo() [2/2]

Box3d& lsst::sphgeom::Box3d::clipTo ( Vector3d const &  b)
inline

clipTo sets this box to the intersection of this box and b.

Definition at line 217 of file Box3d.h.

217  {
218  _intervals[0].clipTo(b.x());
219  _intervals[1].clipTo(b.y());
220  _intervals[2].clipTo(b.z());
221  _enforceInvariants();
222  return *this;
223  }

◆ contains() [1/3]

bool lsst::sphgeom::Box3d::contains ( Box3d const &  b) const
inline

contains returns true iff the intersection of this box and b is equal to b.

Definition at line 164 of file Box3d.h.

164  {
165  return x().contains(b.x()) &&
166  y().contains(b.y()) &&
167  z().contains(b.z());
168  }
bool contains(Scalar x) const
Definition: Interval.h:98

◆ contains() [2/3]

bool lsst::sphgeom::Box3d::contains ( double  x_,
double  y_,
double  z_ 
) const
inline

contains returns true iff the intersection of this box and b is equal to b.

Definition at line 170 of file Box3d.h.

170  {
171  return x().contains(x_) && y().contains(y_) && z().contains(z_);
172  }

◆ contains() [3/3]

bool lsst::sphgeom::Box3d::contains ( Vector3d const &  b) const
inline

contains returns true iff the intersection of this box and b is equal to b.

Definition at line 158 of file Box3d.h.

158  {
159  return x().contains(b.x()) &&
160  y().contains(b.y()) &&
161  z().contains(b.z());
162  }

◆ dilateBy() [1/2]

Box3d& lsst::sphgeom::Box3d::dilateBy ( double  r)
inline

dilateBy minimally expands or shrinks this Box to include or remove all points within distance |r| of its boundary.

If this box is empty or full, or if r is zero, there is no effect. If r is positive, points are added, and if r is negative they are removed.

Definition at line 280 of file Box3d.h.

280 { return dilateBy(r, r, r); }
Box3d & dilateBy(double r)
dilateBy minimally expands or shrinks this Box to include or remove all points within distance |r| of...
Definition: Box3d.h:280

◆ dilateBy() [2/2]

Box3d& lsst::sphgeom::Box3d::dilateBy ( double  w,
double  h,
double  d 
)
inline

dilateBy morphologically dilates or erodes the x, y, and z intervals of this box by w, h, and d.

If w is positive, the x interval is dilated by [-w,w]. If w is zero, the corresponding interval is not modified, and if it is negative, the longitude interval is eroded by [w,-w]. The action of h and d on the y and z intervals is analogous.

If this box is empty or full, there is no effect.

Definition at line 290 of file Box3d.h.

290  {
291  _intervals[0].dilateBy(w);
292  _intervals[1].dilateBy(h);
293  _intervals[2].dilateBy(d);
294  _enforceInvariants();
295  return *this;
296  }
Interval & dilateBy(Scalar x)
For positive x, dilateBy morphologically dilates this interval by [-x,x], which is equivalent to the ...
Definition: Interval.h:230

◆ dilatedBy() [1/2]

Box3d lsst::sphgeom::Box3d::dilatedBy ( double  r) const
inline

Definition at line 281 of file Box3d.h.

281 { return Box3d(*this).dilateBy(r); }

◆ dilatedBy() [2/2]

Box3d lsst::sphgeom::Box3d::dilatedBy ( double  w,
double  h,
double  d 
) const
inline

Definition at line 297 of file Box3d.h.

297  {
298  return Box3d(*this).dilateBy(w, h, d);
299  }

◆ empty()

static Box3d lsst::sphgeom::Box3d::empty ( )
inlinestatic

Definition at line 45 of file Box3d.h.

45  {
46  return Box3d();
47  }

◆ erodeBy() [1/2]

Box3d& lsst::sphgeom::Box3d::erodeBy ( double  r)
inline

Definition at line 300 of file Box3d.h.

300 { return dilateBy(-r); }

◆ erodeBy() [2/2]

Box3d& lsst::sphgeom::Box3d::erodeBy ( double  w,
double  h,
double  d 
)
inline

Definition at line 302 of file Box3d.h.

302  {
303  return dilateBy(-w, -h, -d);
304  }

◆ erodedBy() [1/2]

Box3d lsst::sphgeom::Box3d::erodedBy ( double  r) const
inline

Definition at line 301 of file Box3d.h.

301 { return dilatedBy(-r); }
Box3d dilatedBy(double r) const
Definition: Box3d.h:281

◆ erodedBy() [2/2]

Box3d lsst::sphgeom::Box3d::erodedBy ( double  w,
double  h,
double  d 
) const
inline

Definition at line 305 of file Box3d.h.

305  {
306  return dilatedBy(-w, -h, -d);
307  }

◆ expandedTo() [1/2]

Box3d lsst::sphgeom::Box3d::expandedTo ( Box3d const &  b) const
inline

expandedTo returns the smallest box containing the union of this box and b.

Definition at line 269 of file Box3d.h.

269  {
270  return Box3d(*this).expandTo(b);
271  }

◆ expandedTo() [2/2]

Box3d lsst::sphgeom::Box3d::expandedTo ( Vector3d const &  b) const
inline

expandedTo returns the smallest box containing the union of this box and b.

Definition at line 265 of file Box3d.h.

265  {
266  return Box3d(*this).expandTo(b);
267  }

◆ expandTo() [1/2]

Box3d& lsst::sphgeom::Box3d::expandTo ( Box3d const &  b)
inline

expandTo minimally expands this box to contain b.

Definition at line 254 of file Box3d.h.

254  {
255  _intervals[0].expandTo(b.x());
256  _intervals[1].expandTo(b.y());
257  _intervals[2].expandTo(b.z());
258  return *this;
259  }
Interval & expandTo(Scalar x)
Definition: Interval.h:192

◆ expandTo() [2/2]

Box3d& lsst::sphgeom::Box3d::expandTo ( Vector3d const &  b)
inline

expandTo minimally expands this box to contain b.

Definition at line 247 of file Box3d.h.

247  {
248  _intervals[0].expandTo(b.x());
249  _intervals[1].expandTo(b.y());
250  _intervals[2].expandTo(b.z());
251  return *this;
252  }

◆ full()

static Box3d lsst::sphgeom::Box3d::full ( )
inlinestatic

Definition at line 49 of file Box3d.h.

49  {
50  return Box3d(Interval1d::full(),
53  }
static Interval1d full()
Definition: Interval1d.h:47

◆ getCenter()

Vector3d lsst::sphgeom::Box3d::getCenter ( ) const
inline

getCenter returns the center of this box.

An arbitrary vector is returned for boxes that are empty or full.

Definition at line 139 of file Box3d.h.

139  {
140  return Vector3d(x().getCenter(), y().getCenter(), z().getCenter());
141  }
Vector3d getCenter() const
getCenter returns the center of this box.
Definition: Box3d.h:139

◆ getDepth()

double lsst::sphgeom::Box3d::getDepth ( ) const
inline

getDepth returns the depth (z-axis extent) of this box.

It is negative or NaN for empty boxes, and infinite for full boxes.

Definition at line 153 of file Box3d.h.

153 { return z().getSize(); }
Scalar getSize() const
getSize returns the size (length, width) of this interval.
Definition: Interval.h:93

◆ getHeight()

double lsst::sphgeom::Box3d::getHeight ( ) const
inline

getHeight returns the height (y-axis extent) of this box.

It is negative or NaN for empty boxes, and infinite for full boxes.

Definition at line 149 of file Box3d.h.

149 { return y().getSize(); }

◆ getWidth()

double lsst::sphgeom::Box3d::getWidth ( ) const
inline

getWidth returns the width (x-axis extent) of this box.

It is negative or NaN for empty boxes, and infinite for full boxes.

Definition at line 145 of file Box3d.h.

145 { return x().getSize(); }

◆ intersects() [1/2]

bool lsst::sphgeom::Box3d::intersects ( Box3d const &  b) const
inline

intersects returns true iff the intersection of this box and b is non-empty.

Definition at line 192 of file Box3d.h.

192  {
193  return x().intersects(b.x()) &&
194  y().intersects(b.y()) &&
195  z().intersects(b.z());
196  }
bool intersects(Scalar x) const
Definition: Interval.h:130

◆ intersects() [2/2]

bool lsst::sphgeom::Box3d::intersects ( Vector3d const &  b) const
inline

intersects returns true iff the intersection of this box and b is non-empty.

Definition at line 186 of file Box3d.h.

186  {
187  return x().intersects(b.x()) &&
188  y().intersects(b.y()) &&
189  z().intersects(b.z());
190  }

◆ isDisjointFrom() [1/2]

bool lsst::sphgeom::Box3d::isDisjointFrom ( Box3d const &  b) const
inline

isDisjointFrom returns true iff the intersection of this box and b is empty.

Definition at line 180 of file Box3d.h.

180 { return !intersects(b); }
bool intersects(Vector3d const &b) const
Definition: Box3d.h:186

◆ isDisjointFrom() [2/2]

bool lsst::sphgeom::Box3d::isDisjointFrom ( Vector3d const &  b) const
inline

isDisjointFrom returns true iff the intersection of this box and b is empty.

Definition at line 178 of file Box3d.h.

178 { return !intersects(b); }

◆ isEmpty()

bool lsst::sphgeom::Box3d::isEmpty ( ) const
inline

isEmpty returns true if this box does not contain any points.

Definition at line 128 of file Box3d.h.

128  {
129  return x().isEmpty();
130  }
bool isEmpty() const
isEmpty returns true if this interval does not contain any points.
Definition: Interval.h:83

◆ isFull()

bool lsst::sphgeom::Box3d::isFull ( ) const
inline

isFull returns true if this box contains all points in ℝ³.

Definition at line 133 of file Box3d.h.

133  {
134  return x().isFull() && y().isFull() && z().isFull();
135  }
bool isFull() const
isFull returns true if this interval = ℝ.
Definition: Interval1d.h:62

◆ isWithin() [1/2]

bool lsst::sphgeom::Box3d::isWithin ( Box3d const &  b) const
inline

isWithin returns true if the intersection of this box and b is this box.

Definition at line 208 of file Box3d.h.

208  {
209  return x().isWithin(b.x()) &&
210  y().isWithin(b.y()) &&
211  z().isWithin(b.z());
212  }
bool isWithin(Scalar x) const
Definition: Interval.h:140

◆ isWithin() [2/2]

bool lsst::sphgeom::Box3d::isWithin ( Vector3d const &  b) const
inline

isWithin returns true if the intersection of this box and b is this box.

Definition at line 202 of file Box3d.h.

202  {
203  return x().isWithin(b.x()) &&
204  y().isWithin(b.y()) &&
205  z().isWithin(b.z());
206  }

◆ operator!=() [1/2]

bool lsst::sphgeom::Box3d::operator!= ( Box3d const &  b) const
inline

Definition at line 113 of file Box3d.h.

113 { return !(*this == b); }

◆ operator!=() [2/2]

bool lsst::sphgeom::Box3d::operator!= ( Vector3d const &  v) const
inline

Definition at line 118 of file Box3d.h.

118 { return !(*this == v); }

◆ operator()()

Interval1d lsst::sphgeom::Box3d::operator() ( int  i) const
inline

The function call operator returns the i-th interval of this box.

Definition at line 121 of file Box3d.h.

121 { return _intervals[i]; }

◆ operator==() [1/2]

bool lsst::sphgeom::Box3d::operator== ( Box3d const &  b) const
inline

Two 3D boxes are equal if they contain the same points.

Definition at line 107 of file Box3d.h.

107  {
108  return _intervals[0] == b._intervals[0] &&
109  _intervals[1] == b._intervals[1] &&
110  _intervals[2] == b._intervals[2];
111  }

◆ operator==() [2/2]

bool lsst::sphgeom::Box3d::operator== ( Vector3d const &  v) const
inline

A box is equal to a point if it contains only that point.

Definition at line 116 of file Box3d.h.

116 { return *this == Box3d(v); }

◆ relate() [1/2]

Relationship lsst::sphgeom::Box3d::relate ( Box3d const &  b) const
inline

Definition at line 311 of file Box3d.h.

311  {
312  Relationship xr = x().relate(b.x());
313  Relationship yr = y().relate(b.y());
314  Relationship zr = z().relate(b.z());
315  // If the box x, y, or z intervals are disjoint, then so are the
316  // boxes. The other relationships must hold for all constituent
317  // intervals in order to hold for the boxes.
318  return ((xr & yr & zr) & (CONTAINS | WITHIN)) |
319  ((xr | yr | zr) & DISJOINT);
320  }
Relationship relate(Scalar x) const
Definition: Interval.h:249
std::bitset< 3 > Relationship
Relationship describes how two sets are related.
Definition: Relationship.h:35

◆ relate() [2/2]

Relationship lsst::sphgeom::Box3d::relate ( Vector3d const &  v) const
inline

Definition at line 309 of file Box3d.h.

309 { return relate(Box3d(v)); }
Relationship relate(Vector3d const &v) const
Definition: Box3d.h:309

◆ x()

Interval1d const& lsst::sphgeom::Box3d::x ( ) const
inline

Definition at line 123 of file Box3d.h.

123 { return _intervals[0]; }

◆ y()

Interval1d const& lsst::sphgeom::Box3d::y ( ) const
inline

Definition at line 124 of file Box3d.h.

124 { return _intervals[1]; }

◆ z()

Interval1d const& lsst::sphgeom::Box3d::z ( ) const
inline

Definition at line 125 of file Box3d.h.

125 { return _intervals[2]; }

The documentation for this class was generated from the following file: