LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
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. More...
 
 NormalizedAngleInterval (Angle const &x)
 This constructor creates a closed interval containing only the normalization of x. More...
 
 NormalizedAngleInterval (NormalizedAngle const &x)
 This constructor creates a closed interval containing only x. More...
 
 NormalizedAngleInterval (Angle x, Angle y)
 This constructor creates an interval from the given endpoints. More...
 
 NormalizedAngleInterval (NormalizedAngle x, NormalizedAngle y)
 This constructor creates an interval with the given endpoints. More...
 
bool operator== (NormalizedAngleInterval const &i) const
 Two intervals are equal if they contain the same points. More...
 
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. More...
 
bool operator!= (NormalizedAngle x) const
 
NormalizedAngle getA () const
 getA returns the first endpoint of this interval. More...
 
NormalizedAngle getB () const
 getB returns the second endpoint of this interval. More...
 
bool isEmpty () const
 isEmpty returns true if this interval does not contain any normalized angles. More...
 
bool isFull () const
 isFull returns true if this interval contains all normalized angles. More...
 
bool wraps () const
 wraps returns true if the interval "wraps" around the 0/2π angle discontinuity, i.e. More...
 
NormalizedAngle getCenter () const
 getCenter returns the center of this interval. More...
 
NormalizedAngle getSize () const
 getSize returns the size (length, width) of this interval. More...
 
NormalizedAngleIntervalclipTo (NormalizedAngle x)
 clipTo shrinks this interval until all its points are in x. More...
 
NormalizedAngleIntervalclipTo (NormalizedAngleInterval const &x)
 x.clipTo(y) sets x to the smallest interval containing the intersection of x and y. More...
 
NormalizedAngleInterval clippedTo (NormalizedAngle x) const
 clippedTo returns the intersection of this interval and x. More...
 
NormalizedAngleInterval clippedTo (NormalizedAngleInterval const &x) const
 clippedTo returns the smallest interval containing the intersection of this interval and x. More...
 
NormalizedAngleInterval dilatedBy (Angle x) const
 For positive x, dilatedBy returns the morphological dilation of this interval by [-x,x]. More...
 
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 57 of file NormalizedAngleInterval.h.

Constructor & Destructor Documentation

◆ NormalizedAngleInterval() [1/5]

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

This constructor creates an empty interval.

Definition at line 79 of file NormalizedAngleInterval.h.

79  :
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 84 of file NormalizedAngleInterval.h.

84 : _a(x), _b(_a) {}
double x

◆ NormalizedAngleInterval() [3/5]

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

This constructor creates a closed interval containing only x.

Definition at line 87 of file NormalizedAngleInterval.h.

87  :
88  _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 35 of file NormalizedAngleInterval.cc.

35  {
36  if (x.isNan() || y.isNan()) {
37  *this = empty();
38  return;
39  }
40  if (!x.isNormalized() || !y.isNormalized()) {
41  if (x > y) {
43  "invalid NormalizedAngleInterval endpoints");
44  }
45  if (y - x >= Angle(2.0 * PI)) {
46  *this = full();
47  return;
48  }
49  }
50  _a = NormalizedAngle(x);
51  _b = NormalizedAngle(y);
52 }
int y
Definition: SpanSet.cc:48
static NormalizedAngleInterval empty()
static NormalizedAngleInterval full()
lsst::geom::Angle Angle
Definition: misc.h:33
constexpr double PI
Definition: constants.h:36

◆ NormalizedAngleInterval() [5/5]

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

This constructor creates an interval with the given endpoints.

Definition at line 99 of file NormalizedAngleInterval.h.

99  :
100  _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 214 of file NormalizedAngleInterval.h.

214  {
215  return contains(x) ? NormalizedAngleInterval(x) : empty();
216  }
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 221 of file NormalizedAngleInterval.h.

221  {
222  return NormalizedAngleInterval(*this).clipTo(x);
223  }

◆ 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 203 of file NormalizedAngleInterval.h.

203  {
204  *this = clippedTo(x);
205  return *this;
206  }
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 163 of file NormalizedAngleInterval.cc.

165 {
166  if (x.isEmpty()) {
167  *this = empty();
168  } else if (contains(x._a)) {
169  if (contains(x._b)) {
170  // Both endpoints of x are in this interval. This interval
171  // either contains x, in which case x is the exact intersection,
172  // or the intersection consists of [_a,x._b] ⋃ [x._a,_b].
173  // In both cases, the envelope of the intersection is the shorter
174  // of the two intervals.
175  if (getSize() >= x.getSize()) {
176  *this = x;
177  }
178  } else {
179  _a = x._a;
180  }
181  } else if (contains(x._b)) {
182  _b = x._b;
183  } else if (x.isDisjointFrom(_a)) {
184  *this = empty();
185  }
186  return *this;
187 }
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 150 of file NormalizedAngleInterval.h.

150  {
151  if (x.isNan()) {
152  return true;
153  }
154  return wraps() ? (x <= _b || _a <= x) : (_a <= x && x <= _b);
155  }
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 54 of file NormalizedAngleInterval.cc.

56 {
57  if (x.isEmpty()) {
58  return true;
59  }
60  if (isEmpty()) {
61  return false;
62  }
63  if (x.wraps()) {
64  if (!wraps()) {
65  return isFull();
66  }
67  } else if (wraps()) {
68  return x._a >= _a || x._b <= _b;
69  }
70  return x._a >= _a && x._b <= _b;
71 }
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 253 of file NormalizedAngleInterval.h.

253  {
254  *this = dilatedBy(x);
255  return *this;
256  }
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 232 of file NormalizedAngleInterval.cc.

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

◆ empty()

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

Definition at line 69 of file NormalizedAngleInterval.h.

69  {
70  return NormalizedAngleInterval();
71  }

◆ erodeBy()

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

Definition at line 258 of file NormalizedAngleInterval.h.

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

◆ erodedBy()

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

Definition at line 251 of file NormalizedAngleInterval.h.

251 { 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 237 of file NormalizedAngleInterval.h.

237  {
238  return NormalizedAngleInterval(*this).expandTo(x);
239  }

◆ 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 241 of file NormalizedAngleInterval.h.

241  {
242  return NormalizedAngleInterval(*this).expandTo(x);
243  }

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

191 {
192  if (isEmpty()) {
193  *this = NormalizedAngleInterval(x);
194  } else if (!contains(x)) {
195  if (x.getAngleTo(_a) > _b.getAngleTo(x)) {
196  _b = x;
197  } else {
198  _a = x;
199  }
200  }
201  return *this;
202 }
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 204 of file NormalizedAngleInterval.cc.

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

◆ fromDegrees()

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

Definition at line 60 of file NormalizedAngleInterval.h.

60  {
63  }
static Angle fromDegrees(double a)
Definition: Angle.h:49

◆ fromRadians()

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

Definition at line 65 of file NormalizedAngleInterval.h.

65  {
67  }

◆ full()

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

Definition at line 73 of file NormalizedAngleInterval.h.

73  {
74  return NormalizedAngleInterval(NormalizedAngle(0.0),
75  NormalizedAngle(2.0 * PI));
76  }

◆ getA()

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

getA returns the first endpoint of this interval.

Definition at line 119 of file NormalizedAngleInterval.h.

119 { return _a; }

◆ getB()

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

getB returns the second endpoint of this interval.

Definition at line 122 of file NormalizedAngleInterval.h.

122 { 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 139 of file NormalizedAngleInterval.h.

139 { 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 145 of file NormalizedAngleInterval.h.

145 { 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 173 of file NormalizedAngleInterval.h.

173  {
174  return wraps() ? (x <= _b || _a <= x) : (_a <= x && x <= _b);
175  }

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

177  {
178  return !isDisjointFrom(x);
179  }
bool isDisjointFrom(NormalizedAngle x) const

◆ 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 163 of file NormalizedAngleInterval.h.

163  {
164  return !intersects(x);
165  }

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

75 {
76  if (x.isEmpty() || isEmpty()) {
77  return true;
78  }
79  if (x.wraps()) {
80  return wraps() ? false : (x._a > _b && x._b < _a);
81  }
82  if (wraps()) {
83  return _a > x._b && _b < x._a;
84  }
85  return x._b < _a || x._a > _b;
86 }

◆ isEmpty()

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

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

Definition at line 126 of file NormalizedAngleInterval.h.

126 { 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 129 of file NormalizedAngleInterval.h.

129  {
130  return _a.asRadians() == 0.0 && _b.asRadians() == 2.0 * PI;
131  }
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 185 of file NormalizedAngleInterval.h.

185  {
186  return (_a == x && _b == x) || isEmpty();
187  }

◆ 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 189 of file NormalizedAngleInterval.h.

189  {
190  return x.contains(*this);
191  }

◆ operator!=() [1/2]

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

Definition at line 116 of file NormalizedAngleInterval.h.

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

◆ operator!=() [2/2]

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

Definition at line 107 of file NormalizedAngleInterval.h.

107  {
108  return !(*this == i);
109  }

◆ 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 112 of file NormalizedAngleInterval.h.

112  {
113  return (_a == x && _b == x) || (x.isNan() && isEmpty());
114  }

◆ 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 103 of file NormalizedAngleInterval.h.

103  {
104  return (_a == i._a && _b == i._b) || (isEmpty() && i.isEmpty());
105  }

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

88  {
89  if (isEmpty()) {
90  if (x.isNan()) {
91  return CONTAINS | DISJOINT | WITHIN;
92  }
93  return DISJOINT | WITHIN;
94  }
95  if (x.isNan()) {
96  return CONTAINS | DISJOINT;
97  }
98  if (_a == x && _b == x) {
99  return CONTAINS | WITHIN;
100  }
101  if (intersects(x)) {
102  return CONTAINS;
103  }
104  return DISJOINT;
105 }

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

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

◆ 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 135 of file NormalizedAngleInterval.h.

135 { return _a > _b; }

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