LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
LSST Data Management Base Package
Loading...
Searching...
No Matches
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.
 
 Box3d (Vector3d const &v)
 This constructor creates a box containing a single point.
 
 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()].
 
 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.
 
 Box3d (Interval1d const &x, Interval1d const &y, Interval1d const &z)
 This constructor creates a box spanning the given x, y, and z intervals.
 
bool operator== (Box3d const &b) const
 Two 3D boxes are equal if they contain the same points.
 
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.
 
bool operator!= (Vector3d const &v) const
 
Interval1d operator() (int i) const
 The function call operator returns the i-th interval of this box.
 
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.
 
bool isFull () const
 isFull returns true if this box contains all points in ℝ³.
 
Vector3d getCenter () const
 getCenter returns the center of this box.
 
double getWidth () const
 getWidth returns the width (x-axis extent) of this box.
 
double getHeight () const
 getHeight returns the height (y-axis extent) of this box.
 
double getDepth () const
 getDepth returns the depth (z-axis extent) of this box.
 
Box3ddilateBy (double r)
 dilateBy minimally expands or shrinks this Box to include or remove all points within distance |r| of its boundary.
 
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.
 
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.
 

Detailed Description

Box3d represents a box in ℝ³.

It is the Cartesian product of three intervals of ℝ.

Definition at line 49 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 70 of file Box3d.h.

70{}

◆ Box3d() [2/5]

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

This constructor creates a box containing a single point.

Definition at line 73 of file Box3d.h.

74 {
75 _intervals[0] = Interval1d(v.x());
76 _intervals[1] = Interval1d(v.y());
77 _intervals[2] = Interval1d(v.z());
78 _enforceInvariants();
79 }

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

84 {
85 _intervals[0] = Interval1d(v1.x(), v2.x());
86 _intervals[1] = Interval1d(v1.y(), v2.y());
87 _intervals[2] = Interval1d(v1.z(), v2.z());
88 _enforceInvariants();
89 }

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

94 {
95 _intervals[0] = Interval1d(v.x()).dilatedBy(w);
96 _intervals[1] = Interval1d(v.y()).dilatedBy(h);
97 _intervals[2] = Interval1d(v.z()).dilatedBy(d);
98 _enforceInvariants();
99 }
Derived dilatedBy(Scalar x) const
Definition Interval.h:246
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 103 of file Box3d.h.

106 {
107 _intervals[0] = Interval1d(x);
108 _intervals[1] = Interval1d(y);
109 _intervals[2] = Interval1d(z);
110 _enforceInvariants();
111 }
Interval1d const & x() const
Definition Box3d.h:130
Interval1d const & y() const
Definition Box3d.h:131
Interval1d const & z() const
Definition Box3d.h:132

Member Function Documentation

◆ aroundUnitSphere()

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

aroundUnitSphere returns a minimal Box3d containing the unit sphere.

Definition at line 63 of file Box3d.h.

63 {
64 return Box3d(Interval1d(-1.0, 1.0),
65 Interval1d(-1.0, 1.0),
66 Interval1d(-1.0, 1.0));
67 }
Box3d()
This constructor creates an empty 3D box.
Definition Box3d.h:70

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

247 {
248 return Box3d(*this).clipTo(b);
249 }
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 243 of file Box3d.h.

243 {
244 return Box3d(*this).clipTo(b);
245 }

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

232 {
233 _intervals[0].clipTo(b.x());
234 _intervals[1].clipTo(b.y());
235 _intervals[2].clipTo(b.z());
236 _enforceInvariants();
237 return *this;
238 }
Interval & clipTo(Scalar x)
Definition Interval.h:166

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

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

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

171 {
172 return x().contains(b.x()) &&
173 y().contains(b.y()) &&
174 z().contains(b.z());
175 }
bool contains(Scalar x) const
Definition Interval.h:105

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

177 {
178 return x().contains(x_) && y().contains(y_) && z().contains(z_);
179 }

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

165 {
166 return x().contains(b.x()) &&
167 y().contains(b.y()) &&
168 z().contains(b.z());
169 }

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

287{ 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:287

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

297 {
298 _intervals[0].dilateBy(w);
299 _intervals[1].dilateBy(h);
300 _intervals[2].dilateBy(d);
301 _enforceInvariants();
302 return *this;
303 }
Interval & dilateBy(Scalar x)
For positive x, dilateBy morphologically dilates this interval by [-x,x], which is equivalent to the ...
Definition Interval.h:237

◆ dilatedBy() [1/2]

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

Definition at line 288 of file Box3d.h.

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

◆ dilatedBy() [2/2]

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

Definition at line 304 of file Box3d.h.

304 {
305 return Box3d(*this).dilateBy(w, h, d);
306 }

◆ empty()

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

Definition at line 52 of file Box3d.h.

52 {
53 return Box3d();
54 }

◆ erodeBy() [1/2]

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

Definition at line 307 of file Box3d.h.

307{ return dilateBy(-r); }

◆ erodeBy() [2/2]

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

Definition at line 309 of file Box3d.h.

309 {
310 return dilateBy(-w, -h, -d);
311 }

◆ erodedBy() [1/2]

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

Definition at line 308 of file Box3d.h.

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

◆ erodedBy() [2/2]

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

Definition at line 312 of file Box3d.h.

312 {
313 return dilatedBy(-w, -h, -d);
314 }

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

276 {
277 return Box3d(*this).expandTo(b);
278 }

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

272 {
273 return Box3d(*this).expandTo(b);
274 }

◆ expandTo() [1/2]

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

expandTo minimally expands this box to contain b.

Definition at line 261 of file Box3d.h.

261 {
262 _intervals[0].expandTo(b.x());
263 _intervals[1].expandTo(b.y());
264 _intervals[2].expandTo(b.z());
265 return *this;
266 }
Interval & expandTo(Scalar x)
Definition Interval.h:199

◆ expandTo() [2/2]

Box3d & lsst::sphgeom::Box3d::expandTo ( Vector3d 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 }

◆ full()

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

Definition at line 56 of file Box3d.h.

56 {
57 return Box3d(Interval1d::full(),
60 }
static Interval1d full()
Definition Interval1d.h:55

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

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

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

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

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

156{ 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 152 of file Box3d.h.

152{ 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 199 of file Box3d.h.

199 {
200 return x().intersects(b.x()) &&
201 y().intersects(b.y()) &&
202 z().intersects(b.z());
203 }
bool intersects(Scalar x) const
Definition Interval.h:137

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

193 {
194 return x().intersects(b.x()) &&
195 y().intersects(b.y()) &&
196 z().intersects(b.z());
197 }

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

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

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

185{ 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 135 of file Box3d.h.

135 {
136 return x().isEmpty();
137 }
bool isEmpty() const
isEmpty returns true if this interval does not contain any points.
Definition Interval.h:90

◆ isFull()

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

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

Definition at line 140 of file Box3d.h.

140 {
141 return x().isFull() && y().isFull() && z().isFull();
142 }
bool isFull() const
isFull returns true if this interval = ℝ.
Definition Interval1d.h:70

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

215 {
216 return x().isWithin(b.x()) &&
217 y().isWithin(b.y()) &&
218 z().isWithin(b.z());
219 }
bool isWithin(Scalar x) const
Definition Interval.h:147

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

209 {
210 return x().isWithin(b.x()) &&
211 y().isWithin(b.y()) &&
212 z().isWithin(b.z());
213 }

◆ operator!=() [1/2]

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

Definition at line 120 of file Box3d.h.

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

◆ operator!=() [2/2]

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

Definition at line 125 of file Box3d.h.

125{ 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 128 of file Box3d.h.

128{ 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 114 of file Box3d.h.

114 {
115 return _intervals[0] == b._intervals[0] &&
116 _intervals[1] == b._intervals[1] &&
117 _intervals[2] == b._intervals[2];
118 }

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

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

◆ relate() [1/2]

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

Definition at line 318 of file Box3d.h.

318 {
319 Relationship xr = x().relate(b.x());
320 Relationship yr = y().relate(b.y());
321 Relationship zr = z().relate(b.z());
322 // If the box x, y, or z intervals are disjoint, then so are the
323 // boxes. The other relationships must hold for all constituent
324 // intervals in order to hold for the boxes.
325 return ((xr & yr & zr) & (CONTAINS | WITHIN)) |
326 ((xr | yr | zr) & DISJOINT);
327 }
Relationship relate(Scalar x) const
Definition Interval.h:256
std::bitset< 3 > Relationship
Relationship describes how two sets are related.

◆ relate() [2/2]

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

Definition at line 316 of file Box3d.h.

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

◆ x()

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

Definition at line 130 of file Box3d.h.

130{ return _intervals[0]; }

◆ y()

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

Definition at line 131 of file Box3d.h.

131{ return _intervals[1]; }

◆ z()

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

Definition at line 132 of file Box3d.h.

132{ return _intervals[2]; }

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