LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
SpherePoint.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * See COPYRIGHT file at the top of the source tree.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 #ifndef LSST_AFW_GEOM_SPHEREPOINT_H_
26 #define LSST_AFW_GEOM_SPHEREPOINT_H_
27 
28 #include <ostream>
29 #include <utility>
30 
31 #include "lsst/afw/geom/Angle.h"
32 #include "lsst/afw/geom/Point.h"
33 
34 namespace lsst {
35 namespace afw {
36 namespace geom {
37 
61 #ifndef SWIG
62  final
63 #endif
64 {
65 public:
77  SpherePoint(Angle const& longitude, Angle const& latitude);
78 
90  explicit SpherePoint(Point3D const& vector);
91 
99  SpherePoint(SpherePoint const& other) noexcept;
100 
107  SpherePoint(SpherePoint&& other) noexcept;
108 
121  SpherePoint& operator=(SpherePoint const& other) noexcept;
122 
129  SpherePoint& operator=(SpherePoint&& other) noexcept;
130 
131  /*
132  * Accessors
133  */
134 
147  Angle getLongitude() const noexcept { return _longitude * radians; };
148 
156  Angle getLatitude() const noexcept { return _latitude * radians; };
157 
165  Point3D getVector() const noexcept;
166 
180  Angle operator[](size_t index) const;
181 
190  bool atPole() const noexcept {
191  // Unit tests indicate we don't need to worry about epsilon-errors
192  // Objects constructed from lat=90*degrees, <0,0,1>, etc. all have
193  // atPole() = true. More complex operations like bearingTo have also
194  // been tested near the poles with no ill effects
195  return fabs(_latitude) >= HALFPI;
196  }
197 
207  bool isFinite() const noexcept;
208 
209  /*
210  * Comparisons between points
211  */
212 
232  bool operator==(SpherePoint const& other) const noexcept;
233 
240  bool operator!=(SpherePoint const& other) const noexcept;
241 
261  Angle bearingTo(SpherePoint const& other) const;
262 
272  Angle separation(SpherePoint const& other) const noexcept;
273 
274  /*
275  * Transformations of points
276  */
277 
288  SpherePoint rotated(SpherePoint const& axis, Angle const& amount) const noexcept;
289 
308  SpherePoint offset(Angle const& bearing, Angle const& amount) const;
309 
310 private:
311  // For compatibility with Starlink AST, the implementation must be a
312  // pair of floating-point numbers, with no other data. Do not change
313  // the implementation without an RFC.
314  double _longitude; // radians
315  double _latitude; // radians
316 };
317 
318 /*
319  * Object-level display
320  */
321 
341 std::ostream& operator<<(std::ostream& os, SpherePoint const& point);
342 }
343 }
344 } /* namespace lsst::afw::geom */
345 
346 #endif /* LSST_AFW_GEOM_SPHEREPOINT_H_ */
SpherePoint(Angle const &longitude, Angle const &latitude)
Construct a SpherePoint from a longitude and latitude.
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:60
A coordinate class intended to represent absolute positions.
AngleUnit const radians
constant with units of radians
Definition: Angle.h:90
bool isFinite() const noexcept
true if this point is a well-defined position.
SpherePoint offset(Angle const &bearing, Angle const &amount) const
Return a point offset from this one along a great circle.
table::Key< geom::Angle > latitude
Definition: VisitInfo.cc:172
A coordinate class intended to represent absolute positions.
A class representing an Angle.
Definition: Angle.h:103
Angle bearingTo(SpherePoint const &other) const
Direction from one point to another.
table::Key< geom::Angle > longitude
Definition: VisitInfo.cc:173
Angle separation(SpherePoint const &other) const noexcept
Angular distance between two points.
SpherePoint rotated(SpherePoint const &axis, Angle const &amount) const noexcept
Return a point rotated from this one around an axis.
Angle getLatitude() const noexcept
The latitude of this point.
Definition: SpherePoint.h:156
double const HALFPI
Definition: Angle.h:19
Angle getLongitude() const noexcept
The longitude of this point.
Definition: SpherePoint.h:147
SpherePoint & operator=(SpherePoint const &other) noexcept
Overwrite this object with the value of another SpherePoint.
bool atPole() const noexcept
true if this point is either coordinate pole.
Definition: SpherePoint.h:190
Point3D getVector() const noexcept
A unit vector representation of this point.