LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
NormalizedAngleInterval.h
Go to the documentation of this file.
1/*
2 * LSST Data Management System
3 * Copyright 2014-2015 AURA/LSST.
4 *
5 * This product includes software developed by the
6 * LSST Project (http://www.lsst.org/).
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the LSST License Statement and
19 * the GNU General Public License along with this program. If not,
20 * see <https://www.lsstcorp.org/LegalNotices/>.
21 */
22
23#ifndef LSST_SPHGEOM_NORMALIZEDANGLEINTERVAL_H_
24#define LSST_SPHGEOM_NORMALIZEDANGLEINTERVAL_H_
25
29
30#include <iosfwd>
31
32#include "NormalizedAngle.h"
33#include "Relationship.h"
34
35
36namespace lsst {
37namespace sphgeom {
38
58public:
59 // Factory functions
60 static NormalizedAngleInterval fromDegrees(double a, double b) {
63 }
64
65 static NormalizedAngleInterval fromRadians(double a, double b) {
67 }
68
71 }
72
75 NormalizedAngle(2.0 * PI));
76 }
77
80 _a(NormalizedAngle::nan()), _b(NormalizedAngle::nan()) {}
81
84 explicit NormalizedAngleInterval(Angle const & x) : _a(x), _b(_a) {}
85
88 _a(x), _b(x) {}
89
97
100 _a(x), _b(y) {}
101
103 bool operator==(NormalizedAngleInterval const & i) const {
104 return (_a == i._a && _b == i._b) || (isEmpty() && i.isEmpty());
105 }
106
107 bool operator!=(NormalizedAngleInterval const & i) const {
108 return !(*this == i);
109 }
110
113 return (_a == x && _b == x) || (x.isNan() && isEmpty());
114 }
115
116 bool operator!=(NormalizedAngle x) const { return !(*this == x); }
117
119 NormalizedAngle getA() const { return _a; }
120
122 NormalizedAngle getB() const { return _b; }
123
126 bool isEmpty() const { return _a.isNan() || _b.isNan(); }
127
129 bool isFull() const {
130 return _a.asRadians() == 0.0 && _b.asRadians() == 2.0 * PI;
131 }
132
135 bool wraps() const { return _a > _b; }
136
140
145 NormalizedAngle getSize() const { return _a.getAngleTo(_b); }
146
151 if (x.isNan()) {
152 return true;
153 }
154 return wraps() ? (x <= _b || _a <= x) : (_a <= x && x <= _b);
155 }
156
157 bool contains(NormalizedAngleInterval const & x) const;
159
164 return !intersects(x);
165 }
166
167 bool isDisjointFrom(NormalizedAngleInterval const & x) const;
169
174 return wraps() ? (x <= _b || _a <= x) : (_a <= x && x <= _b);
175 }
176
178 return !isDisjointFrom(x);
179 }
181
186 return (_a == x && _b == x) || isEmpty();
187 }
188
189 bool isWithin(NormalizedAngleInterval const & x) const {
190 return x.contains(*this);
191 }
193
201
204 *this = clippedTo(x);
205 return *this;
206 }
207
212
216 }
217
222 return NormalizedAngleInterval(*this).clipTo(x);
223 }
224
232
238 return NormalizedAngleInterval(*this).expandTo(x);
239 }
240
242 return NormalizedAngleInterval(*this).expandTo(x);
243 }
245
252
254 *this = dilatedBy(x);
255 return *this;
256 }
257
259
260private:
263};
264
265std::ostream & operator<<(std::ostream &, NormalizedAngleInterval const &);
266
267}} // namespace lsst::sphgeom
268
269#endif // LSST_SPHGEOM_NORMALIZEDANGLEINTERVAL_H_
double x
This file declares a class for representing normalized angles.
int y
Definition: SpanSet.cc:48
table::Key< int > b
table::Key< int > a
Angle represents an angle in radians.
Definition: Angle.h:43
static Angle fromDegrees(double a)
Definition: Angle.h:49
NormalizedAngle is an angle that lies in the range [0, 2π), with one exception - a NormalizedAngle ca...
bool isNan() const
isNan returns true if the angle value is NaN.
double asRadians() const
asRadians returns the value of this angle in units of radians.
NormalizedAngle getAngleTo(NormalizedAngle const &a) const
getAngleTo computes the angle α ∈ [0, 2π) such that adding α to this angle and then normalizing the r...
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...
NormalizedAngleInterval represents closed intervals of normalized angles, i.e.
static NormalizedAngleInterval empty()
bool isFull() const
isFull returns true if this interval contains all normalized angles.
bool isDisjointFrom(NormalizedAngle x) const
NormalizedAngleInterval()
This constructor creates an empty interval.
bool wraps() const
wraps returns true if the interval "wraps" around the 0/2π angle discontinuity, i....
NormalizedAngleInterval clippedTo(NormalizedAngleInterval const &x) const
clippedTo returns the smallest interval containing the intersection of this interval and x.
NormalizedAngleInterval & clipTo(NormalizedAngle x)
clipTo shrinks this interval until all its points are in x.
NormalizedAngleInterval(NormalizedAngle x, NormalizedAngle y)
This constructor creates an interval with the given endpoints.
NormalizedAngle getA() const
getA returns the first endpoint of this interval.
NormalizedAngle getCenter() const
getCenter returns the center of this interval.
bool intersects(NormalizedAngleInterval const &x) const
bool operator==(NormalizedAngle x) const
A closed interval is equal to a point x if both endpoints equal x.
NormalizedAngleInterval & erodeBy(Angle x)
NormalizedAngleInterval(Angle const &x)
This constructor creates a closed interval containing only the normalization of x.
bool isWithin(NormalizedAngleInterval const &x) const
NormalizedAngleInterval expandedTo(NormalizedAngleInterval const &x) const
NormalizedAngleInterval dilatedBy(Angle x) const
For positive x, dilatedBy returns the morphological dilation of this interval by [-x,...
Relationship relate(NormalizedAngle x) const
NormalizedAngleInterval erodedBy(Angle x) const
NormalizedAngleInterval & dilateBy(Angle x)
NormalizedAngleInterval expandedTo(NormalizedAngle x) const
NormalizedAngle getSize() const
getSize returns the size (length, width) of this interval.
NormalizedAngleInterval & expandTo(NormalizedAngle x)
NormalizedAngle getB() const
getB returns the second endpoint of this interval.
bool operator==(NormalizedAngleInterval const &i) const
Two intervals are equal if they contain the same points.
NormalizedAngleInterval(NormalizedAngle const &x)
This constructor creates a closed interval containing only x.
bool operator!=(NormalizedAngleInterval const &i) const
static NormalizedAngleInterval fromDegrees(double a, double b)
static NormalizedAngleInterval fromRadians(double a, double b)
NormalizedAngleInterval clippedTo(NormalizedAngle x) const
clippedTo returns the intersection of this interval and x.
static NormalizedAngleInterval full()
bool isEmpty() const
isEmpty returns true if this interval does not contain any normalized angles.
lsst::geom::Angle Angle
Definition: misc.h:33
std::ostream & operator<<(std::ostream &, Angle const &)
Definition: Angle.cc:34
constexpr double PI
Definition: constants.h:36
A base class for image defects.
This file provides a type alias for describing set relationships.