Loading [MathJax]/extensions/tex2jax.js
LSST Applications 28.0.0,g1653933729+a8ce1bb630,g1a997c3884+a8ce1bb630,g28da252d5a+5bd70b7e6d,g2bbee38e9b+638fca75ac,g2bc492864f+638fca75ac,g3156d2b45e+07302053f8,g347aa1857d+638fca75ac,g35bb328faa+a8ce1bb630,g3a166c0a6a+638fca75ac,g3e281a1b8c+7bbb0b2507,g4005a62e65+17cd334064,g414038480c+5b5cd4fff3,g41af890bb2+4ffae9de63,g4e1a3235cc+0f1912dca3,g6249c6f860+3c3976f90c,g80478fca09+46aba80bd6,g82479be7b0+77990446f6,g858d7b2824+78ba4d1ce1,g89c8672015+f667a5183b,g9125e01d80+a8ce1bb630,ga5288a1d22+2a6264e9ca,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc22bb204ba+78ba4d1ce1,gc28159a63d+638fca75ac,gcf0d15dbbd+32ddb6096f,gd6b7c0dfd1+3e339405e9,gda3e153d99+78ba4d1ce1,gda6a2b7d83+32ddb6096f,gdaeeff99f8+1711a396fd,gdd5a9049c5+b18c39e5e3,ge2409df99d+a5e4577cdc,ge33fd446bb+78ba4d1ce1,ge79ae78c31+638fca75ac,gf0baf85859+64e8883e75,gf5289d68f6+e1b046a8d7,gfa443fc69c+91d9ed1ecf,gfda6b12a05+8419469a56
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
lsst::sphgeom::Interval1d Class Reference

Interval1d represents closed intervals of ℝ. More...

#include <Interval1d.h>

Inheritance diagram for lsst::sphgeom::Interval1d:
lsst::sphgeom::Interval< Interval1d, double >

Public Member Functions

 Interval1d ()
 
 Interval1d (double x)
 
 Interval1d (double x, double y)
 
 Interval1d (Base const &base)
 
bool isFull () const
 isFull returns true if this interval = ℝ.
 
bool operator== (Interval const &i) const
 Two closed intervals are equal if their endpoints are the same, or both are empty.
 
bool operator== (double x) const
 A closed interval is equal to a point x if both endpoints equal x.
 
bool operator!= (Interval const &i) const
 
bool operator!= (double x) const
 
double getA () const
 getA returns the lower endpoint of this interval.
 
double getB () const
 getB returns the upper endpoint of this interval.
 
bool isEmpty () const
 isEmpty returns true if this interval does not contain any points.
 
double getCenter () const
 getCenter returns the center of this interval.
 
double getSize () const
 getSize returns the size (length, width) of this interval.
 
IntervaldilateBy (double x)
 For positive x, dilateBy morphologically dilates this interval by [-x,x], which is equivalent to the taking the Minkowski sum with [-x,x].
 
IntervalerodeBy (double x)
 
Interval1d dilatedBy (double x) const
 
Interval1d erodedBy (double x) const
 
bool contains (double x) const
 
bool contains (Interval const &x) const
 
bool isDisjointFrom (double x) const
 
bool isDisjointFrom (Interval const &x) const
 
bool intersects (double x) const
 
bool intersects (Interval const &x) const
 
bool isWithin (double x) const
 
bool isWithin (Interval const &x) const
 
Relationship relate (double x) const
 
Relationship relate (Interval const &x) const
 
IntervalclipTo (double x)
 
IntervalclipTo (Interval const &x)
 
Interval1d clippedTo (double x) const
 
Interval1d clippedTo (Interval const &x) const
 
IntervalexpandTo (double x)
 
IntervalexpandTo (Interval const &x)
 
Interval1d expandedTo (double x) const
 
Interval1d expandedTo (Interval const &x) const
 

Static Public Member Functions

static Interval1d empty ()
 
static Interval1d full ()
 

Detailed Description

Interval1d represents closed intervals of ℝ.

It can represent both empty and full intervals, as well as single points.

Definition at line 47 of file Interval1d.h.

Constructor & Destructor Documentation

◆ Interval1d() [1/4]

lsst::sphgeom::Interval1d::Interval1d ( )
inline

Definition at line 61 of file Interval1d.h.

61: Base() {}

◆ Interval1d() [2/4]

lsst::sphgeom::Interval1d::Interval1d ( double x)
inlineexplicit

Definition at line 63 of file Interval1d.h.

63: Base(x) {}

◆ Interval1d() [3/4]

lsst::sphgeom::Interval1d::Interval1d ( double x,
double y )
inline

Definition at line 65 of file Interval1d.h.

65: Base(x, y) {}
int y
Definition SpanSet.cc:48

◆ Interval1d() [4/4]

lsst::sphgeom::Interval1d::Interval1d ( Base const & base)
inline

Definition at line 67 of file Interval1d.h.

67: Base(base) {}

Member Function Documentation

◆ clippedTo() [1/2]

Interval1d lsst::sphgeom::Interval< Interval1d, double >::clippedTo ( double x) const
inlineinherited

clippedTo returns the intersection of this interval and x.

Definition at line 190 of file Interval.h.

190{ return Interval(*this).clipTo(x); }

◆ clippedTo() [2/2]

Interval1d lsst::sphgeom::Interval< Interval1d, double >::clippedTo ( Interval< Interval1d, double > const & x) const
inlineinherited

clippedTo returns the intersection of this interval and x.

Definition at line 192 of file Interval.h.

192 {
193 return Interval(*this).clipTo(x);
194 }

◆ clipTo() [1/2]

Interval & lsst::sphgeom::Interval< Interval1d, double >::clipTo ( double x)
inlineinherited

clipTo shrinks this interval until all its points are in x.

Definition at line 166 of file Interval.h.

166 {
167 if (x != x) {
168 _a = x;
169 _b = x;
170 } else {
171 _a = std::max(_a, x);
172 _b = std::min(_b, x);
173 }
174 return *this;
175 }
T max(T... args)
T min(T... args)

◆ clipTo() [2/2]

Interval & lsst::sphgeom::Interval< Interval1d, double >::clipTo ( Interval< Interval1d, double > const & x)
inlineinherited

clipTo shrinks this interval until all its points are in x.

Definition at line 177 of file Interval.h.

177 {
178 if (x.isEmpty()) {
179 *this = x;
180 } else if (!isEmpty()) {
181 _a = std::max(_a, x._a);
182 _b = std::min(_b, x._b);
183 }
184 return *this;
185 }

◆ contains() [1/2]

bool lsst::sphgeom::Interval< Interval1d, double >::contains ( double x) const
inlineinherited

contains returns true if the intersection of this interval and x is equal to x.

Definition at line 105 of file Interval.h.

105 {
106 return (_a <= x && x <= _b) || x != x;
107 }

◆ contains() [2/2]

bool lsst::sphgeom::Interval< Interval1d, double >::contains ( Interval< Interval1d, double > const & x) const
inlineinherited

contains returns true if the intersection of this interval and x is equal to x.

Definition at line 109 of file Interval.h.

109 {
110 if (x.isEmpty()) {
111 return true;
112 } else if (isEmpty()) {
113 return false;
114 }
115 return _a <= x._a && _b >= x._b;
116 }

◆ dilateBy()

Interval & lsst::sphgeom::Interval< Interval1d, double >::dilateBy ( double x)
inlineinherited

For positive x, dilateBy morphologically dilates this interval by [-x,x], which is equivalent to the taking the Minkowski sum with [-x,x].

For negative x, it morphologically erodes this interval by [x,-x]. If x is zero or NaN, or this interval is empty, there is no effect.

Definition at line 237 of file Interval.h.

237 {
238 if (x == x && !isEmpty()) {
239 _a = _a - x;
240 _b = _b + x;
241 }
242 return *this;
243 }

◆ dilatedBy()

Interval1d lsst::sphgeom::Interval< Interval1d, double >::dilatedBy ( double x) const
inlineinherited

Definition at line 246 of file Interval.h.

246{ return Interval(*this).dilateBy(x); }

◆ empty()

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

Definition at line 51 of file Interval1d.h.

51 {
52 return Interval1d();
53 }

◆ erodeBy()

Interval & lsst::sphgeom::Interval< Interval1d, double >::erodeBy ( double x)
inlineinherited

Definition at line 245 of file Interval.h.

245{ return dilateBy(-x); }

◆ erodedBy()

Interval1d lsst::sphgeom::Interval< Interval1d, double >::erodedBy ( double x) const
inlineinherited

Definition at line 247 of file Interval.h.

247{ return Interval(*this).erodeBy(x); }

◆ expandedTo() [1/2]

Interval1d lsst::sphgeom::Interval< Interval1d, double >::expandedTo ( double x) const
inlineinherited

expandedTo returns the smallest interval containing the union of this interval and x.

Definition at line 225 of file Interval.h.

225{ return Interval(*this).expandTo(x); }

◆ expandedTo() [2/2]

Interval1d lsst::sphgeom::Interval< Interval1d, double >::expandedTo ( Interval< Interval1d, double > const & x) const
inlineinherited

expandedTo returns the smallest interval containing the union of this interval and x.

Definition at line 227 of file Interval.h.

227 {
228 return Interval(*this).expandTo(x);
229 }

◆ expandTo() [1/2]

Interval & lsst::sphgeom::Interval< Interval1d, double >::expandTo ( double x)
inlineinherited

expandTo minimally expands this interval to contain x.

Definition at line 199 of file Interval.h.

199 {
200 if (isEmpty()) {
201 _a = x;
202 _b = x;
203 } else if (x < _a) {
204 _a = x;
205 } else if (x > _b) {
206 _b = x;
207 }
208 return *this;
209 }

◆ expandTo() [2/2]

Interval & lsst::sphgeom::Interval< Interval1d, double >::expandTo ( Interval< Interval1d, double > const & x)
inlineinherited

expandTo minimally expands this interval to contain x.

Definition at line 211 of file Interval.h.

211 {
212 if (isEmpty()) {
213 *this = x;
214 } else if (!x.isEmpty()) {
215 _a = std::min(_a, x._a);
216 _b = std::max(_b, x._b);
217 }
218 return *this;
219 }

◆ full()

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

◆ getA()

double lsst::sphgeom::Interval< Interval1d, double >::getA ( ) const
inlineinherited

getA returns the lower endpoint of this interval.

The return value for empty intervals is arbitrary.

Definition at line 83 of file Interval.h.

83{ return _a; }

◆ getB()

double lsst::sphgeom::Interval< Interval1d, double >::getB ( ) const
inlineinherited

getB returns the upper endpoint of this interval.

The return value for empty intervals is arbitrary.

Definition at line 87 of file Interval.h.

87{ return _b; }

◆ getCenter()

double lsst::sphgeom::Interval< Interval1d, double >::getCenter ( ) const
inlineinherited

getCenter returns the center of this interval.

It is arbitrary for empty intervals.

Definition at line 96 of file Interval.h.

96{ return 0.5 * (_a + _b); }

◆ getSize()

double lsst::sphgeom::Interval< Interval1d, double >::getSize ( ) const
inlineinherited

getSize returns the size (length, width) of this interval.

It is zero for single-point intervals, and NaN or negative for empty intervals.

Definition at line 100 of file Interval.h.

100{ return _b - _a; }

◆ intersects() [1/2]

bool lsst::sphgeom::Interval< Interval1d, double >::intersects ( double x) const
inlineinherited

intersects returns true if the intersection of this interval and x is non-empty.

Definition at line 137 of file Interval.h.

137{ return _a <= x && x <= _b; }

◆ intersects() [2/2]

bool lsst::sphgeom::Interval< Interval1d, double >::intersects ( Interval< Interval1d, double > const & x) const
inlineinherited

intersects returns true if the intersection of this interval and x is non-empty.

Definition at line 139 of file Interval.h.

139 {
140 return !isDisjointFrom(x);
141 }

◆ isDisjointFrom() [1/2]

bool lsst::sphgeom::Interval< Interval1d, double >::isDisjointFrom ( double x) const
inlineinherited

isDisjointFrom returns true if the intersection of this interval and x is empty.

Definition at line 122 of file Interval.h.

122 {
123 return !intersects(x);
124 }

◆ isDisjointFrom() [2/2]

bool lsst::sphgeom::Interval< Interval1d, double >::isDisjointFrom ( Interval< Interval1d, double > const & x) const
inlineinherited

isDisjointFrom returns true if the intersection of this interval and x is empty.

Definition at line 126 of file Interval.h.

126 {
127 if (isEmpty() || x.isEmpty()) {
128 return true;
129 }
130 return _a > x._b || _b < x._a;
131 }

◆ isEmpty()

bool lsst::sphgeom::Interval< Interval1d, double >::isEmpty ( ) const
inlineinherited

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

Definition at line 90 of file Interval.h.

90 {
91 return !(_a <= _b); // returns true when _a and/or _b is NaN
92 }

◆ isFull()

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

isFull returns true if this interval = ℝ.

Definition at line 70 of file Interval1d.h.

◆ isWithin() [1/2]

bool lsst::sphgeom::Interval< Interval1d, double >::isWithin ( double x) const
inlineinherited

isWithin returns true if the intersection of this interval and x is this interval.

Definition at line 147 of file Interval.h.

147 {
148 return (_a == x && _b == x) || isEmpty();
149 }

◆ isWithin() [2/2]

bool lsst::sphgeom::Interval< Interval1d, double >::isWithin ( Interval< Interval1d, double > const & x) const
inlineinherited

isWithin returns true if the intersection of this interval and x is this interval.

Definition at line 151 of file Interval.h.

151 {
152 return x.contains(*this);
153 }

◆ operator!=() [1/2]

bool lsst::sphgeom::Interval< Interval1d, double >::operator!= ( double x) const
inlineinherited

Definition at line 79 of file Interval.h.

79{ return !(*this == x); }

◆ operator!=() [2/2]

bool lsst::sphgeom::Interval< Interval1d, double >::operator!= ( Interval< Interval1d, double > const & i) const
inlineinherited

Definition at line 72 of file Interval.h.

72{ return !(*this == i); }

◆ operator==() [1/2]

bool lsst::sphgeom::Interval< Interval1d, double >::operator== ( double x) const
inlineinherited

A closed interval is equal to a point x if both endpoints equal x.

Definition at line 75 of file Interval.h.

75 {
76 return (_a == x && _b == x) || (x != x && isEmpty());
77 }

◆ operator==() [2/2]

bool lsst::sphgeom::Interval< Interval1d, double >::operator== ( Interval< Interval1d, double > const & i) const
inlineinherited

Two closed intervals are equal if their endpoints are the same, or both are empty.

Definition at line 68 of file Interval.h.

68 {
69 return (_a == i._a && _b == i._b) || (i.isEmpty() && isEmpty());
70 }

◆ relate() [1/2]

Relationship lsst::sphgeom::Interval< Interval1d, double >::relate ( double x) const
inherited

relate returns a bitset S describing the spatial relationships between this interval and x. For each relation that holds, the bitwise AND of S and the corresponding Relationship will be non-zero.

Definition at line 160 of file Interval.h.

256 {
257 if (isEmpty()) {
258 if (x != x) {
259 return CONTAINS | DISJOINT | WITHIN;
260 }
261 return DISJOINT | WITHIN;
262 }
263 if (x != x) {
264 return CONTAINS | DISJOINT;
265 }
266 if (_a == x && _b == x) {
267 return CONTAINS | WITHIN;
268 }
269 if (intersects(x)) {
270 return CONTAINS;
271 }
272 return DISJOINT;
273}

◆ relate() [2/2]

Relationship lsst::sphgeom::Interval< Interval1d, double >::relate ( Interval< Interval1d, double > const & x) const
inherited

relate returns a bitset S describing the spatial relationships between this interval and x. For each relation that holds, the bitwise AND of S and the corresponding Relationship will be non-zero.

Definition at line 161 of file Interval.h.

278{
279 if (isEmpty()) {
280 if (x.isEmpty()) {
281 return CONTAINS | DISJOINT | WITHIN;
282 }
283 return DISJOINT | WITHIN;
284 }
285 if (x.isEmpty()) {
286 return CONTAINS | DISJOINT;
287 }
288 if (_a == x._a && _b == x._b) {
289 return CONTAINS | WITHIN;
290 }
291 if (_a > x._b || _b < x._a) {
292 return DISJOINT;
293 }
294 if (_a <= x._a && _b >= x._b) {
295 return CONTAINS;
296 }
297 if (x._a <= _a && x._b >= _b) {
298 return WITHIN;
299 }
300 return INTERSECTS;
301}

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