LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
lsst::sphgeom::NormalizedAngleInterval Class Reference

NormalizedAngleInterval represents closed intervals of normalized angles, i.e. More...

#include <NormalizedAngleInterval.h>

Public Member Functions

 NormalizedAngleInterval ()
 This constructor creates an empty interval.
 
 NormalizedAngleInterval (Angle const &x)
 This constructor creates a closed interval containing only the normalization of x.
 
 NormalizedAngleInterval (NormalizedAngle const &x)
 This constructor creates a closed interval containing only x.
 
 NormalizedAngleInterval (Angle x, Angle y)
 This constructor creates an interval from the given endpoints.
 
 NormalizedAngleInterval (NormalizedAngle x, NormalizedAngle y)
 This constructor creates an interval with the given endpoints.
 
bool operator== (NormalizedAngleInterval const &i) const
 Two intervals are equal if they contain the same points.
 
bool operator!= (NormalizedAngleInterval const &i) const
 
bool operator== (NormalizedAngle x) const
 A closed interval is equal to a point x if both endpoints equal x.
 
bool operator!= (NormalizedAngle x) const
 
NormalizedAngle getA () const
 getA returns the first endpoint of this interval.
 
NormalizedAngle getB () const
 getB returns the second endpoint of this interval.
 
bool isEmpty () const
 isEmpty returns true if this interval does not contain any normalized angles.
 
bool isFull () const
 isFull returns true if this interval contains all normalized angles.
 
bool wraps () const
 wraps returns true if the interval "wraps" around the 0/2π angle discontinuity, i.e.
 
NormalizedAngle getCenter () const
 getCenter returns the center of this interval.
 
NormalizedAngle getSize () const
 getSize returns the size (length, width) of this interval.
 
NormalizedAngleIntervalclipTo (NormalizedAngle x)
 clipTo shrinks this interval until all its points are in x.
 
NormalizedAngleIntervalclipTo (NormalizedAngleInterval const &x)
 x.clipTo(y) sets x to the smallest interval containing the intersection of x and y.
 
NormalizedAngleInterval clippedTo (NormalizedAngle x) const
 clippedTo returns the intersection of this interval and x.
 
NormalizedAngleInterval clippedTo (NormalizedAngleInterval const &x) const
 clippedTo returns the smallest interval containing the intersection of this interval and x.
 
NormalizedAngleInterval dilatedBy (Angle x) const
 For positive x, dilatedBy returns the morphological dilation of this interval by [-x,x].
 
NormalizedAngleInterval erodedBy (Angle x) const
 
NormalizedAngleIntervaldilateBy (Angle x)
 
NormalizedAngleIntervalerodeBy (Angle x)
 
bool contains (NormalizedAngle x) const
 
bool contains (NormalizedAngleInterval const &x) const
 
bool isDisjointFrom (NormalizedAngle x) const
 
bool isDisjointFrom (NormalizedAngleInterval const &x) const
 
bool intersects (NormalizedAngle x) const
 
bool intersects (NormalizedAngleInterval const &x) const
 
bool isWithin (NormalizedAngle x) const
 
bool isWithin (NormalizedAngleInterval const &x) const
 
Relationship relate (NormalizedAngle x) const
 
Relationship relate (NormalizedAngleInterval const &x) const
 
NormalizedAngleIntervalexpandTo (NormalizedAngle x)
 
NormalizedAngleIntervalexpandTo (NormalizedAngleInterval const &x)
 
NormalizedAngleInterval expandedTo (NormalizedAngle x) const
 
NormalizedAngleInterval expandedTo (NormalizedAngleInterval const &x) const
 

Static Public Member Functions

static NormalizedAngleInterval fromDegrees (double a, double b)
 
static NormalizedAngleInterval fromRadians (double a, double b)
 
static NormalizedAngleInterval empty ()
 
static NormalizedAngleInterval full ()
 

Detailed Description

NormalizedAngleInterval represents closed intervals of normalized angles, i.e.

intervals of the unit circle.

A point on the unit circle is represented by the angle ∈ [0, 2π) between it and a reference point, and an interval by a pair of bounding points a and b. The points in the interval are traced out by counter-clockwise rotation of a around the circle until it reaches b. Because the endpoints are represented via normalized angles, a can be greater than b, indicating that the interval consists of the points represented by angles [a, 2π) ⋃ [0, b]. When this is the case, calling wraps() on the interval will return true.

An interval with identical endpoints contains just that point, and is equal to that point.

An interval with NaN as either endpoint is empty, meaning that it contains no points on the unit circle. The interval [0, 2 * PI] is full, meaning that it contains all representable normalized angles in [0, 2π).

Definition at line 64 of file NormalizedAngleInterval.h.

Constructor & Destructor Documentation

◆ NormalizedAngleInterval() [1/5]

lsst::sphgeom::NormalizedAngleInterval::NormalizedAngleInterval ( )
inline

This constructor creates an empty interval.

Definition at line 86 of file NormalizedAngleInterval.h.

86 :
static NormalizedAngle nan()

◆ NormalizedAngleInterval() [2/5]

lsst::sphgeom::NormalizedAngleInterval::NormalizedAngleInterval ( Angle const & x)
inlineexplicit

This constructor creates a closed interval containing only the normalization of x.

Definition at line 91 of file NormalizedAngleInterval.h.

91: _a(x), _b(_a) {}

◆ NormalizedAngleInterval() [3/5]

lsst::sphgeom::NormalizedAngleInterval::NormalizedAngleInterval ( NormalizedAngle const & x)
inlineexplicit

This constructor creates a closed interval containing only x.

Definition at line 94 of file NormalizedAngleInterval.h.

94 :
95 _a(x), _b(x) {}

◆ NormalizedAngleInterval() [4/5]

lsst::sphgeom::NormalizedAngleInterval::NormalizedAngleInterval ( Angle x,
Angle y )

This constructor creates an interval from the given endpoints.

If both x and y lie in the range [0, 2π), then y may be less than x. For example, passing in x = 3π/2 and y = π/2 will result in an interval containing angles [3π/2, 2π) ⋃ [0, π/2]. Otherwise, x must be less than or equal to y, and the interval will correspond to the the set of angles produced by normalizing the elements of the interval [x, y].

Definition at line 42 of file NormalizedAngleInterval.cc.

42 {
43 if (x.isNan() || y.isNan()) {
44 *this = empty();
45 return;
46 }
47 if (!x.isNormalized() || !y.isNormalized()) {
48 if (x > y) {
50 "invalid NormalizedAngleInterval endpoints");
51 }
52 if (y - x >= Angle(2.0 * PI)) {
53 *this = full();
54 return;
55 }
56 }
57 _a = NormalizedAngle(x);
58 _b = NormalizedAngle(y);
59}
int y
Definition SpanSet.cc:48
static NormalizedAngleInterval empty()
static NormalizedAngleInterval full()
constexpr double PI
Definition constants.h:43

◆ NormalizedAngleInterval() [5/5]

lsst::sphgeom::NormalizedAngleInterval::NormalizedAngleInterval ( NormalizedAngle x,
NormalizedAngle y )
inline

This constructor creates an interval with the given endpoints.

Definition at line 106 of file NormalizedAngleInterval.h.

106 :
107 _a(x), _b(y) {}

Member Function Documentation

◆ clippedTo() [1/2]

NormalizedAngleInterval lsst::sphgeom::NormalizedAngleInterval::clippedTo ( NormalizedAngle x) const
inline

clippedTo returns the intersection of this interval and x.

Definition at line 221 of file NormalizedAngleInterval.h.

221 {
223 }
NormalizedAngleInterval()
This constructor creates an empty interval.

◆ clippedTo() [2/2]

NormalizedAngleInterval lsst::sphgeom::NormalizedAngleInterval::clippedTo ( NormalizedAngleInterval const & x) const
inline

clippedTo returns the smallest interval containing the intersection of this interval and x.

The result is not always unique, and x.clippedTo(y) is not guaranteed to equal y.clippedTo(x).

Definition at line 228 of file NormalizedAngleInterval.h.

228 {
229 return NormalizedAngleInterval(*this).clipTo(x);
230 }

◆ clipTo() [1/2]

NormalizedAngleInterval & lsst::sphgeom::NormalizedAngleInterval::clipTo ( NormalizedAngle x)
inline

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

Definition at line 210 of file NormalizedAngleInterval.h.

210 {
211 *this = clippedTo(x);
212 return *this;
213 }
NormalizedAngleInterval clippedTo(NormalizedAngle x) const
clippedTo returns the intersection of this interval and x.

◆ clipTo() [2/2]

NormalizedAngleInterval & lsst::sphgeom::NormalizedAngleInterval::clipTo ( NormalizedAngleInterval const & x)

x.clipTo(y) sets x to the smallest interval containing the intersection of x and y.

The result is not always unique, and x.clipTo(y) is not guaranteed to equal y.clipTo(x).

Definition at line 170 of file NormalizedAngleInterval.cc.

172{
173 if (x.isEmpty()) {
174 *this = empty();
175 } else if (contains(x._a)) {
176 if (contains(x._b)) {
177 // Both endpoints of x are in this interval. This interval
178 // either contains x, in which case x is the exact intersection,
179 // or the intersection consists of [_a,x._b] ⋃ [x._a,_b].
180 // In both cases, the envelope of the intersection is the shorter
181 // of the two intervals.
182 if (getSize() >= x.getSize()) {
183 *this = x;
184 }
185 } else {
186 _a = x._a;
187 }
188 } else if (contains(x._b)) {
189 _b = x._b;
190 } else if (x.isDisjointFrom(_a)) {
191 *this = empty();
192 }
193 return *this;
194}
NormalizedAngle getSize() const
getSize returns the size (length, width) of this interval.

◆ contains() [1/2]

bool lsst::sphgeom::NormalizedAngleInterval::contains ( NormalizedAngle x) const
inline

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

Definition at line 157 of file NormalizedAngleInterval.h.

157 {
158 if (x.isNan()) {
159 return true;
160 }
161 return wraps() ? (x <= _b || _a <= x) : (_a <= x && x <= _b);
162 }
bool wraps() const
wraps returns true if the interval "wraps" around the 0/2π angle discontinuity, i....

◆ contains() [2/2]

bool lsst::sphgeom::NormalizedAngleInterval::contains ( NormalizedAngleInterval const & x) const

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

Definition at line 61 of file NormalizedAngleInterval.cc.

63{
64 if (x.isEmpty()) {
65 return true;
66 }
67 if (isEmpty()) {
68 return false;
69 }
70 if (x.wraps()) {
71 if (!wraps()) {
72 return isFull();
73 }
74 } else if (wraps()) {
75 return x._a >= _a || x._b <= _b;
76 }
77 return x._a >= _a && x._b <= _b;
78}
bool isFull() const
isFull returns true if this interval contains all normalized angles.
bool isEmpty() const
isEmpty returns true if this interval does not contain any normalized angles.

◆ dilateBy()

NormalizedAngleInterval & lsst::sphgeom::NormalizedAngleInterval::dilateBy ( Angle x)
inline

Definition at line 260 of file NormalizedAngleInterval.h.

260 {
261 *this = dilatedBy(x);
262 return *this;
263 }
NormalizedAngleInterval dilatedBy(Angle x) const
For positive x, dilatedBy returns the morphological dilation of this interval by [-x,...

◆ dilatedBy()

NormalizedAngleInterval lsst::sphgeom::NormalizedAngleInterval::dilatedBy ( Angle x) const

For positive x, dilatedBy returns the morphological dilation of this interval by [-x,x].

For negative x, it returns the morphological erosion of this interval by [x,-x]. If x is zero or NaN, or this interval is empty, there is no effect.

Definition at line 239 of file NormalizedAngleInterval.cc.

239 {
240 if (isEmpty() || isFull() || x == Angle(0.0) || x.isNan()) {
241 return *this;
242 }
243 Angle a = _a - x;
244 Angle b = _b + x;
245 if (x > Angle(0.0)) {
246 // x is a dilation.
247 if (x >= Angle(PI)) { return full(); }
248 if (wraps()) {
249 // The undilated interval wraps. If the dilated one does not,
250 // then decreasing a from _a and increasing b from _b has
251 // caused b and a to cross.
252 if (a <= b) { return full(); }
253 } else {
254 // The undilated interval does not wrap. If either a or b
255 // is not normalized then the dilated interval must either
256 // wrap or be full.
257 if (a < Angle(0.0)) {
258 a = a + Angle(2.0 * PI);
259 if (a <= b) { return full(); }
260 }
261 if (b > Angle(2.0 * PI)) {
262 b = b - Angle(2.0 * PI);
263 if (a <= b) { return full(); }
264 }
265 }
266 } else {
267 // x is an erosion.
268 if (x <= Angle(-PI)) { return empty(); }
269 if (wraps()) {
270 // The uneroded interval wraps. If either a or b is not
271 // normalized, then either the eroded interval does not wrap,
272 // or it is empty.
273 if (a > Angle(2.0 * PI)) {
274 a = a - Angle(2.0 * PI);
275 if (a > b) { return empty(); }
276 }
277 if (b < Angle(0.0)) {
278 b = b + Angle(2.0 * PI);
279 if (a > b) { return empty(); }
280 }
281 } else {
282 // The uneroded interval does not wrap. If the eroded one does,
283 // then increasing a from _a and decreasing b from _b has
284 // caused a and b to cross.
285 if (a > b) { return empty(); }
286 }
287 }
288 return NormalizedAngleInterval(a, b);
289}
table::Key< int > b

◆ empty()

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

Definition at line 76 of file NormalizedAngleInterval.h.

76 {
78 }

◆ erodeBy()

NormalizedAngleInterval & lsst::sphgeom::NormalizedAngleInterval::erodeBy ( Angle x)
inline

Definition at line 265 of file NormalizedAngleInterval.h.

265{ return dilateBy(-x); }
NormalizedAngleInterval & dilateBy(Angle x)

◆ erodedBy()

NormalizedAngleInterval lsst::sphgeom::NormalizedAngleInterval::erodedBy ( Angle x) const
inline

Definition at line 258 of file NormalizedAngleInterval.h.

258{ return dilatedBy(-x); }

◆ expandedTo() [1/2]

NormalizedAngleInterval lsst::sphgeom::NormalizedAngleInterval::expandedTo ( NormalizedAngle x) const
inline

expandedTo returns the smallest interval containing the union of this interval and x. The result is not always unique, and x.expandedTo(y) is not guaranteed to equal y.expandedTo(x).

Definition at line 244 of file NormalizedAngleInterval.h.

244 {
245 return NormalizedAngleInterval(*this).expandTo(x);
246 }

◆ expandedTo() [2/2]

NormalizedAngleInterval lsst::sphgeom::NormalizedAngleInterval::expandedTo ( NormalizedAngleInterval const & x) const
inline

expandedTo returns the smallest interval containing the union of this interval and x. The result is not always unique, and x.expandedTo(y) is not guaranteed to equal y.expandedTo(x).

Definition at line 248 of file NormalizedAngleInterval.h.

248 {
249 return NormalizedAngleInterval(*this).expandTo(x);
250 }

◆ expandTo() [1/2]

NormalizedAngleInterval & lsst::sphgeom::NormalizedAngleInterval::expandTo ( NormalizedAngle x)

expandTo minimally expands this interval to contain x. The result is not always unique, and x.expandTo(y) is not guaranteed to equal y.expandTo(x).

Definition at line 196 of file NormalizedAngleInterval.cc.

198{
199 if (isEmpty()) {
200 *this = NormalizedAngleInterval(x);
201 } else if (!contains(x)) {
202 if (x.getAngleTo(_a) > _b.getAngleTo(x)) {
203 _b = x;
204 } else {
205 _a = x;
206 }
207 }
208 return *this;
209}
NormalizedAngle getAngleTo(NormalizedAngle const &a) const
getAngleTo computes the angle α ∈ [0, 2π) such that adding α to this angle and then normalizing the r...

◆ expandTo() [2/2]

NormalizedAngleInterval & lsst::sphgeom::NormalizedAngleInterval::expandTo ( NormalizedAngleInterval const & x)

expandTo minimally expands this interval to contain x. The result is not always unique, and x.expandTo(y) is not guaranteed to equal y.expandTo(x).

Definition at line 211 of file NormalizedAngleInterval.cc.

213{
214 if (!x.isEmpty()) {
215 if (contains(x._a)) {
216 if (contains(x._b)) {
217 // Both endpoints of x are in this interval. This interval
218 // either contains x, in which case this interval is the
219 // desired union, or the union is the full interval.
220 if (wraps() != x.wraps()) {
221 *this = full();
222 }
223 } else {
224 _b = x._b;
225 }
226 } else if (contains(x._b)) {
227 _a = x._a;
228 } else if (isEmpty() || x.contains(_a)) {
229 *this = x;
230 } else if (_b.getAngleTo(x._a) < x._b.getAngleTo(_a)) {
231 _b = x._b;
232 } else {
233 _a = x._a;
234 }
235 }
236 return *this;
237}

◆ fromDegrees()

static NormalizedAngleInterval lsst::sphgeom::NormalizedAngleInterval::fromDegrees ( double a,
double b )
inlinestatic

Definition at line 67 of file NormalizedAngleInterval.h.

67 {
70 }
static Angle fromDegrees(double a)
Definition Angle.h:56

◆ fromRadians()

static NormalizedAngleInterval lsst::sphgeom::NormalizedAngleInterval::fromRadians ( double a,
double b )
inlinestatic

Definition at line 72 of file NormalizedAngleInterval.h.

72 {
73 return NormalizedAngleInterval(Angle(a), Angle(b));
74 }

◆ full()

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

Definition at line 80 of file NormalizedAngleInterval.h.

80 {
81 return NormalizedAngleInterval(NormalizedAngle(0.0),
82 NormalizedAngle(2.0 * PI));
83 }

◆ getA()

NormalizedAngle lsst::sphgeom::NormalizedAngleInterval::getA ( ) const
inline

getA returns the first endpoint of this interval.

Definition at line 126 of file NormalizedAngleInterval.h.

126{ return _a; }

◆ getB()

NormalizedAngle lsst::sphgeom::NormalizedAngleInterval::getB ( ) const
inline

getB returns the second endpoint of this interval.

Definition at line 129 of file NormalizedAngleInterval.h.

129{ return _b; }

◆ getCenter()

NormalizedAngle lsst::sphgeom::NormalizedAngleInterval::getCenter ( ) const
inline

getCenter returns the center of this interval.

It is NaN for empty intervals, and arbitrary for full intervals.

Definition at line 146 of file NormalizedAngleInterval.h.

146{ return NormalizedAngle::center(_a, _b); }
static NormalizedAngle center(NormalizedAngle const &a, NormalizedAngle const &b)
For two normalized angles a and b, center(a, b) returns the angle m such that a.getAngleTo(m) is equa...

◆ getSize()

NormalizedAngle lsst::sphgeom::NormalizedAngleInterval::getSize ( ) const
inline

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

It is zero for single-point intervals, and NaN for empty intervals. Note that due to rounding errors, an interval with size 2 * PI is not necessarily full, and an interval with size 0 may contain more than a single point.

Definition at line 152 of file NormalizedAngleInterval.h.

152{ return _a.getAngleTo(_b); }

◆ intersects() [1/2]

bool lsst::sphgeom::NormalizedAngleInterval::intersects ( NormalizedAngle x) const
inline

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

Definition at line 180 of file NormalizedAngleInterval.h.

180 {
181 return wraps() ? (x <= _b || _a <= x) : (_a <= x && x <= _b);
182 }

◆ intersects() [2/2]

bool lsst::sphgeom::NormalizedAngleInterval::intersects ( NormalizedAngleInterval const & x) const
inline

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

Definition at line 184 of file NormalizedAngleInterval.h.

184 {
185 return !isDisjointFrom(x);
186 }

◆ isDisjointFrom() [1/2]

bool lsst::sphgeom::NormalizedAngleInterval::isDisjointFrom ( NormalizedAngle x) const
inline

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

Definition at line 170 of file NormalizedAngleInterval.h.

170 {
171 return !intersects(x);
172 }

◆ isDisjointFrom() [2/2]

bool lsst::sphgeom::NormalizedAngleInterval::isDisjointFrom ( NormalizedAngleInterval const & x) const

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

Definition at line 80 of file NormalizedAngleInterval.cc.

82{
83 if (x.isEmpty() || isEmpty()) {
84 return true;
85 }
86 if (x.wraps()) {
87 return wraps() ? false : (x._a > _b && x._b < _a);
88 }
89 if (wraps()) {
90 return _a > x._b && _b < x._a;
91 }
92 return x._b < _a || x._a > _b;
93}

◆ isEmpty()

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

isEmpty returns true if this interval does not contain any normalized angles.

Definition at line 133 of file NormalizedAngleInterval.h.

133{ return _a.isNan() || _b.isNan(); }
bool isNan() const
isNan returns true if the angle value is NaN.

◆ isFull()

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

isFull returns true if this interval contains all normalized angles.

Definition at line 136 of file NormalizedAngleInterval.h.

136 {
137 return _a.asRadians() == 0.0 && _b.asRadians() == 2.0 * PI;
138 }
double asRadians() const
asRadians returns the value of this angle in units of radians.

◆ isWithin() [1/2]

bool lsst::sphgeom::NormalizedAngleInterval::isWithin ( NormalizedAngle x) const
inline

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

Definition at line 192 of file NormalizedAngleInterval.h.

192 {
193 return (_a == x && _b == x) || isEmpty();
194 }

◆ isWithin() [2/2]

bool lsst::sphgeom::NormalizedAngleInterval::isWithin ( NormalizedAngleInterval const & x) const
inline

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

Definition at line 196 of file NormalizedAngleInterval.h.

196 {
197 return x.contains(*this);
198 }

◆ operator!=() [1/2]

bool lsst::sphgeom::NormalizedAngleInterval::operator!= ( NormalizedAngle x) const
inline

Definition at line 123 of file NormalizedAngleInterval.h.

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

◆ operator!=() [2/2]

bool lsst::sphgeom::NormalizedAngleInterval::operator!= ( NormalizedAngleInterval const & i) const
inline

Definition at line 114 of file NormalizedAngleInterval.h.

114 {
115 return !(*this == i);
116 }

◆ operator==() [1/2]

bool lsst::sphgeom::NormalizedAngleInterval::operator== ( NormalizedAngle x) const
inline

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

Definition at line 119 of file NormalizedAngleInterval.h.

119 {
120 return (_a == x && _b == x) || (x.isNan() && isEmpty());
121 }

◆ operator==() [2/2]

bool lsst::sphgeom::NormalizedAngleInterval::operator== ( NormalizedAngleInterval const & i) const
inline

Two intervals are equal if they contain the same points.

Definition at line 110 of file NormalizedAngleInterval.h.

110 {
111 return (_a == i._a && _b == i._b) || (isEmpty() && i.isEmpty());
112 }

◆ relate() [1/2]

Relationship lsst::sphgeom::NormalizedAngleInterval::relate ( NormalizedAngle x) const

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 95 of file NormalizedAngleInterval.cc.

95 {
96 if (isEmpty()) {
97 if (x.isNan()) {
98 return CONTAINS | DISJOINT | WITHIN;
99 }
100 return DISJOINT | WITHIN;
101 }
102 if (x.isNan()) {
103 return CONTAINS | DISJOINT;
104 }
105 if (_a == x && _b == x) {
106 return CONTAINS | WITHIN;
107 }
108 if (intersects(x)) {
109 return CONTAINS;
110 }
111 return DISJOINT;
112}

◆ relate() [2/2]

Relationship lsst::sphgeom::NormalizedAngleInterval::relate ( NormalizedAngleInterval const & x) const

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 114 of file NormalizedAngleInterval.cc.

116{
117 if (isEmpty()) {
118 if (x.isEmpty()) {
119 return CONTAINS | DISJOINT | WITHIN;
120 }
121 return DISJOINT | WITHIN;
122 }
123 if (x.isEmpty()) {
124 return CONTAINS | DISJOINT;
125 }
126 if (_a == x._a && _b == x._b) {
127 return CONTAINS | WITHIN;
128 }
129 // The intervals are not the same, and neither is empty.
130 if (wraps()) {
131 if (x.wraps()) {
132 // Both intervals wrap.
133 if (_a <= x._a && _b >= x._b) {
134 return CONTAINS;
135 }
136 if (_a >= x._a && _b <= x._b) {
137 return WITHIN;
138 }
139 return INTERSECTS;
140 }
141 // x does not wrap.
142 if (x.isFull()) {
143 return WITHIN;
144 }
145 if (_a <= x._a || _b >= x._b) {
146 return CONTAINS;
147 }
148 return (_a > x._b && _b < x._a) ? DISJOINT : INTERSECTS;
149 }
150 if (x.wraps()) {
151 // This interval does not wrap.
152 if (isFull()) {
153 return CONTAINS;
154 }
155 if (x._a <= _a || x._b >= _b) {
156 return WITHIN;
157 }
158 return (x._a > _b && x._b < _a) ? DISJOINT : INTERSECTS;
159 }
160 // Neither interval wraps.
161 if (_a <= x._a && _b >= x._b) {
162 return CONTAINS;
163 }
164 if (_a >= x._a && _b <= x._b) {
165 return WITHIN;
166 }
167 return (_a <= x._b && _b >= x._a) ? INTERSECTS : DISJOINT;
168}

◆ wraps()

bool lsst::sphgeom::NormalizedAngleInterval::wraps ( ) const
inline

wraps returns true if the interval "wraps" around the 0/2π angle discontinuity, i.e.

consists of [getA(), 2π) ∪ [0, getB()].

Definition at line 142 of file NormalizedAngleInterval.h.

142{ return _a > _b; }

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