LSSTApplications  20.0.0
LSSTDataManagementBasePackage
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 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  }

◆ 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  }

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  }

◆ 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 236 of file Box3d.h.

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

◆ 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 232 of file Box3d.h.

232  {
233  return Box3d(*this).clipTo(b);
234  }

◆ 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 221 of file Box3d.h.

221  {
222  _intervals[0].clipTo(b.x());
223  _intervals[1].clipTo(b.y());
224  _intervals[2].clipTo(b.z());
225  _enforceInvariants();
226  return *this;
227  }

◆ 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 213 of file Box3d.h.

213  {
214  _intervals[0].clipTo(b.x());
215  _intervals[1].clipTo(b.y());
216  _intervals[2].clipTo(b.z());
217  _enforceInvariants();
218  return *this;
219  }

◆ contains() [1/2]

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  }

◆ contains() [2/2]

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 276 of file Box3d.h.

276 { return dilateBy(r, r, r); }

◆ 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 286 of file Box3d.h.

286  {
287  _intervals[0].dilateBy(w);
288  _intervals[1].dilateBy(h);
289  _intervals[2].dilateBy(d);
290  _enforceInvariants();
291  return *this;
292  }

◆ dilatedBy() [1/2]

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

Definition at line 277 of file Box3d.h.

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

◆ dilatedBy() [2/2]

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

Definition at line 293 of file Box3d.h.

293  {
294  return Box3d(*this).dilateBy(w, h, d);
295  }

◆ 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 296 of file Box3d.h.

296 { return dilateBy(-r); }

◆ erodeBy() [2/2]

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

Definition at line 298 of file Box3d.h.

298  {
299  return dilateBy(-w, -h, -d);
300  }

◆ erodedBy() [1/2]

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

Definition at line 297 of file Box3d.h.

297 { return dilatedBy(-r); }

◆ erodedBy() [2/2]

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

Definition at line 301 of file Box3d.h.

301  {
302  return dilatedBy(-w, -h, -d);
303  }

◆ 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 265 of file Box3d.h.

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

◆ 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 261 of file Box3d.h.

261  {
262  return Box3d(*this).expandTo(b);
263  }

◆ expandTo() [1/2]

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

expandTo minimally expands this box to contain b.

Definition at line 250 of file Box3d.h.

250  {
251  _intervals[0].expandTo(b.x());
252  _intervals[1].expandTo(b.y());
253  _intervals[2].expandTo(b.z());
254  return *this;
255  }

◆ expandTo() [2/2]

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

expandTo minimally expands this box to contain b.

Definition at line 243 of file Box3d.h.

243  {
244  _intervals[0].expandTo(b.x());
245  _intervals[1].expandTo(b.y());
246  _intervals[2].expandTo(b.z());
247  return *this;
248  }

◆ full()

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

Definition at line 49 of file Box3d.h.

49  {
50  return Box3d(Interval1d::full(),
53  }

◆ 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  }

◆ 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(); }

◆ 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 188 of file Box3d.h.

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

◆ 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 182 of file Box3d.h.

182  {
183  return x().intersects(b.x()) &&
184  y().intersects(b.y()) &&
185  z().intersects(b.z());
186  }

◆ 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 176 of file Box3d.h.

176 { return !intersects(b); }

◆ 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 174 of file Box3d.h.

174 { 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  }

◆ 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  }

◆ 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 204 of file Box3d.h.

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

◆ 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 198 of file Box3d.h.

198  {
199  return x().isWithin(b.x()) &&
200  y().isWithin(b.y()) &&
201  z().isWithin(b.z());
202  }

◆ 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 307 of file Box3d.h.

307  {
308  Relationship xr = x().relate(b.x());
309  Relationship yr = y().relate(b.y());
310  Relationship zr = z().relate(b.z());
311  // If the box x, y, or z intervals are disjoint, then so are the
312  // boxes. The other relationships must hold for all constituent
313  // intervals in order to hold for the boxes.
314  return ((xr & yr & zr) & (CONTAINS | WITHIN)) |
315  ((xr | yr | zr) & DISJOINT);
316  }

◆ relate() [2/2]

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

Definition at line 305 of file Box3d.h.

305 { return relate(Box3d(v)); }

◆ 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:
lsst::sphgeom::Box3d::intersects
bool intersects(Vector3d const &b) const
Definition: Box3d.h:182
lsst::sphgeom::Box3d::relate
Relationship relate(Vector3d const &v) const
Definition: Box3d.h:305
lsst::sphgeom::Box3d::dilateBy
Box3d & dilateBy(double r)
dilateBy minimally expands or shrinks this Box to include or remove all points within distance |r| of...
Definition: Box3d.h:276
lsst::sphgeom::Box3d::dilatedBy
Box3d dilatedBy(double r) const
Definition: Box3d.h:277
lsst::sphgeom::Box3d::Box3d
Box3d()
This constructor creates an empty 3D box.
Definition: Box3d.h:63
lsst::sphgeom::Interval::clipTo
Interval & clipTo(Scalar x)
Definition: Interval.h:159
lsst::sphgeom::Interval::getSize
Scalar getSize() const
getSize returns the size (length, width) of this interval.
Definition: Interval.h:93
lsst::sphgeom::Box3d::x
Interval1d const & x() const
Definition: Box3d.h:123
lsst::sphgeom::Interval::isEmpty
bool isEmpty() const
isEmpty returns true if this interval does not contain any points.
Definition: Interval.h:83
lsst::sphgeom::Interval::relate
Relationship relate(Scalar x) const
Definition: Interval.h:249
lsst::sphgeom::Box3d::getCenter
Vector3d getCenter() const
getCenter returns the center of this box.
Definition: Box3d.h:139
lsst::sphgeom::Interval::contains
bool contains(Scalar x) const
Definition: Interval.h:98
lsst::sphgeom::Interval::isWithin
bool isWithin(Scalar x) const
Definition: Interval.h:140
lsst::sphgeom::Box3d::z
Interval1d const & z() const
Definition: Box3d.h:125
lsst::sphgeom::Relationship
std::bitset< 3 > Relationship
Relationship describes how two sets are related.
Definition: Relationship.h:35
b
table::Key< int > b
Definition: TransmissionCurve.cc:467
lsst::sphgeom::Interval1d::isFull
bool isFull() const
isFull returns true if this interval = ℝ.
Definition: Interval1d.h:62
lsst::sphgeom::Interval1d::full
static Interval1d full()
Definition: Interval1d.h:47
w
double w
Definition: CoaddPsf.cc:69
lsst::sphgeom::Interval::dilateBy
Interval & dilateBy(Scalar x)
For positive x, dilateBy morphologically dilates this interval by [-x,x], which is equivalent to the ...
Definition: Interval.h:230
lsst::sphgeom::Interval::expandTo
Interval & expandTo(Scalar x)
Definition: Interval.h:192
lsst::sphgeom::Interval::intersects
bool intersects(Scalar x) const
Definition: Interval.h:130
lsst::sphgeom::Interval::dilatedBy
Derived dilatedBy(Scalar x) const
Definition: Interval.h:239
lsst::sphgeom::Box3d::y
Interval1d const & y() const
Definition: Box3d.h:124