LSSTApplications
19.0.0-14-gb0260a2+16456dd421,20.0.0+44dbdb3492,20.0.0+5d43f57eb7,20.0.0+8a208d85ec,20.0.0+a295394073,20.0.0+f15d39cacd,20.0.0-1-g253301a+8a208d85ec,20.0.0-1-g5b95a8c+fc0c0df92e,20.0.0-16-g760a3dc6+b31208f437,20.0.0-18-gcabc0c9fd+54cb7ade16,20.0.0-2-g4dae9ad+71e3c9ad45,20.0.0-2-g61b8584+b4ab3064f8,20.0.0-2-ga51b5d4+1f4ba438e8,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+c85f3a4c63,20.0.0-2-gf072044+8a208d85ec,20.0.0-2-gf1f7952+71e3c9ad45,20.0.0-22-g54e2caa+3351092962,20.0.0-25-g5eafb0f+71e3c9ad45,20.0.0-28-g73474ed+3c7e226ea7,20.0.0-29-g1235a2f+d30e658c1c,20.0.0-3-g8f21e14+558cb18951,20.0.0-3-gbd60e8c+ffb20d0b0d,20.0.0-3-gbecbe05+7f0063ada4,20.0.0-4-g4bc9b9f+57161cfff5,20.0.0-4-gb4befbc+0e003188f4,20.0.0-4-gf910f65+b4ab3064f8,20.0.0-43-gfec247c5+985768289e,20.0.0-5-gcbc8587+3c7e226ea7,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g4aa86cc+b6dcff6f8d,20.0.0-6-g9a5b7a1+4bc2181c53,20.0.0-6-gd222c45+7040a8a6f6,20.0.0-74-g0218c7a+7d276c6844,20.0.0-9-g4aef684+90bf294a58,20.0.0-9-g5051ac2+d529cf1a41,w.2020.47
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
21 #ifndef LSST_GEOM_ANGLE_H
22 #define LSST_GEOM_ANGLE_H
26 #include <type_traits>
28 #include "boost/math/constants/constants.hpp"
36 #pragma clang diagnostic push
37 #pragma clang diagnostic ignored "-Wunused-variable"
38 double constexpr
PI = boost::math::constants::pi<double>();
40 double constexpr
TWOPI = boost::math::constants::pi<double>() * 2.0;
41 double constexpr
HALFPI = boost::math::constants::pi<double>() * 0.5;
42 double constexpr
ONE_OVER_PI = 1.0 / boost::math::constants::pi<double>();
44 double const SQRTPI = sqrt(boost::math::constants::pi<double>());
45 double const INVSQRTPI = 1.0 / sqrt(boost::math::constants::pi<double>());
46 double constexpr
ROOT2 = boost::math::constants::root_two<double>();
47 #pragma clang diagnostic pop
51 inline constexpr
double degToRad(
double x) noexcept {
return x *
PI / 180.; }
52 inline constexpr
double radToDeg(
double x) noexcept {
return x * 180. /
PI; }
53 inline constexpr
double radToArcsec(
double x) noexcept {
return x * 3600. * 180. /
PI; }
54 inline constexpr
double radToMas(
double x) noexcept {
return x * 1000. * 3600. * 180. /
PI; }
55 inline constexpr
double arcsecToRad(
double x) noexcept {
return (
x / 3600.) *
PI / 180.; }
56 inline constexpr
double masToRad(
double x) noexcept {
return (
x / (1000. * 3600.)) *
PI / 180.; }
105 return (_val == rhs._val);
139 constexpr
Angle() noexcept : _val(0) {}
156 constexpr
operator double() const noexcept {
return _val; }
235 #define ANGLE_OPUP_TYPE(OP, TYPE) \
236 Angle& operator OP(TYPE const& d) noexcept { \
257 #undef ANGLE_OPUP_TYPE
259 #define ANGLE_COMP(OP) \
260 constexpr bool operator OP(const Angle& rhs) const noexcept { return _val OP rhs._val; }
287 #define ANGLE_OP(OP) \
288 inline constexpr Angle operator OP(Angle a, Angle d) noexcept { \
289 return Angle(static_cast<double>(a) OP static_cast<double>(d)); \
294 #define ANGLE_OP_TYPE(OP, TYPE) \
295 inline constexpr Angle operator OP(Angle a, TYPE d) noexcept { \
296 return Angle(static_cast<double>(a) OP d); \
299 inline constexpr Angle operator OP(TYPE d, Angle a) noexcept { \
300 return Angle(d OP static_cast<double>(a)); \
359 template <
typename T>
379 template <
typename T>
394 template <
typename T>
397 "Only numeric types may be multiplied by an AngleUnit to create an Angle!");
398 return Angle(lhs * rhs._val);
406 if (wrapped < 0.0) wrapped +=
TWOPI;
408 if (wrapped >=
TWOPI) wrapped = 0.0;
421 }
else if (wrapped >=
PI) {
434 double const refAngRad = refAng.
asRadians();
435 double wrapped = (*
this - refAng).wrapCtr().asRadians() + refAngRad;
440 if (wrapped - refAngRad >=
PI) {
443 if (wrapped - refAngRad < -
PI) {
470 #endif // if !defined(LSST_GEOM_ANGLE_H)
constexpr AngleUnit degrees
constant with units of degrees
constexpr bool isAngle(T) noexcept
Allow a user to check if they have an angle.
Angle separation(Angle const &other) const noexcept
The signed difference between two Angles.
constexpr double radToDeg(double x) noexcept
constexpr double masToRad(double x) noexcept
constexpr double PI
The ratio of a circle's circumference to diameter.
Angle wrapCtr() const noexcept
Wrap this angle to the range [-π, π).
Angle wrap() const noexcept
Wrap this angle to the range [0, 2π).
constexpr AngleUnit arcseconds
constant with units of arcseconds
constexpr double asArcminutes() const noexcept
Return an Angle's value in arcminutes.
constexpr double ONE_OVER_PI
constexpr Angle(double val, AngleUnit units=radians) noexcept
Construct an Angle with the specified value (interpreted in the given units).
constexpr Angle operator-(Angle a, Angle d) noexcept
Difference of two angles.
constexpr Angle() noexcept
Construct the zero angle.
table::Key< double > angle
size_t operator()(argument_type const &x) const noexcept
constexpr double radToArcsec(double x) noexcept
constexpr friend Angle operator*(T lhs, AngleUnit rhs) noexcept
Use AngleUnit to convert a POD (e.g. int, double) to an Angle; e.g. 180*degrees.
constexpr AngleUnit hours
constant with units of hours
constexpr double asRadians() const noexcept
Return an Angle's value in radians.
constexpr Angle(Angle &&other) noexcept=default
Move constructor.
std::size_t hash_value() const noexcept
Return a hash of this object.
ItemVariant const * other
constexpr AngleUnit milliarcseconds
constant with units of milliarcseconds
constexpr bool operator==(AngleUnit const &rhs) const noexcept
Test if two units are the same.
constexpr Angle operator*(Angle a, Angle d) noexcept
Product of two angles.
Angle & operator=(Angle const &other) noexcept=default
Copy assignment.
constexpr double radToMas(double x) noexcept
std::size_t hash_value() const noexcept
Return a hash of this object.
Angle & operator=(Angle &&other) noexcept=default
Move assignment.
A base class for image defects.
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
constexpr double degToRad(double x) noexcept
constexpr double asAngularUnits(AngleUnit const &units) const noexcept
Return an Angle's value in the specified units.
constexpr AngleUnit arcminutes
constant with units of arcminutes
#define ANGLE_OPUP_TYPE(OP, TYPE)
constexpr Angle(Angle const &other) noexcept=default
Copy constructor.
constexpr Angle operator/(Angle a, int d) noexcept
Ratio of an angle and a scalar.
constexpr double asHours() const noexcept
Return an Angle's value in hours.
A class used to convert scalar POD types such as double to Angle.
#define ANGLE_OP_TYPE(OP, TYPE)
A class representing an angle.
constexpr AngleUnit radians
constant with units of radians
constexpr double asDegrees() const noexcept
Return an Angle's value in degrees.
size_t operator()(argument_type const &x) const noexcept
Angle wrapNear(Angle const &refAng) const noexcept
Wrap this angle to a value x such that -π ≤ x - refAng ≤ π, approximately.
constexpr double asMilliarcseconds() const noexcept
Return an Angle's value in milliarcseconds.
constexpr double asArcseconds() const noexcept
Return an Angle's value in arcseconds.
constexpr AngleUnit(double val)
Define a new angle unit.
constexpr double arcsecToRad(double x) noexcept