1 #if !defined(LSST_AFW_GEOM_ANGLE_H)
2 #define LSST_AFW_GEOM_ANGLE_H
6 #include <boost/math/constants/constants.hpp>
8 #include <boost/static_assert.hpp>
10 namespace lsst {
namespace afw {
namespace geom {
16 #pragma clang diagnostic push
17 #pragma clang diagnostic ignored "-Wunused-variable"
18 double const PI = boost::math::constants::pi<double>();
19 double const TWOPI = boost::math::constants::pi<double>() * 2.0;
20 double const HALFPI = boost::math::constants::pi<double>() * 0.5;
21 double const ONE_OVER_PI = 1.0 / boost::math::constants::pi<double>();
22 double const SQRTPI = sqrt(boost::math::constants::pi<double>());
23 double const INVSQRTPI = 1.0/sqrt(boost::math::constants::pi<double>());
24 double const ROOT2 = boost::math::constants::root_two<double>();
25 #pragma clang diagnostic pop
36 return x * 3600. * 180. /
PI;
39 return x * 1000. * 3600. * 180. /
PI;
42 return (x / 3600.) *
PI / 180.;
45 return (x / (1000. * 3600.)) *
PI / 180.;
52 #if 0 && !defined(M_PI) // a good idea, but with ramifications
53 # define M_PI ::lsst::afw::geom::PI
83 return (_val == rhs.
_val);
113 operator double()
const {
return _val; }
135 return (std::acos(1. - d2/2.)) *
radians;
197 if (
_val - refAngRad >=
PI) {
201 if (
_val - refAngRad < -
PI) {
202 _val -=
_val * 2.0 * std::numeric_limits<double>::epsilon();
207 #define ANGLE_OPUP_TYPE(OP, TYPE) \
208 Angle& operator OP(TYPE const& d) { \
220 #undef ANGLE_OPUP_TYPE
222 #define ANGLE_COMP(OP) \
223 bool operator OP ( const Angle& rhs ) { \
224 return _val OP rhs._val; \
250 #define ANGLE_OP(OP) \
251 inline const Angle operator OP(Angle const a, Angle const d) { \
252 return Angle(static_cast<double>(a) OP static_cast<double>(d)); \
255 #define ANGLE_OP_TYPE(OP, TYPE) \
256 inline const Angle operator OP(Angle const a, TYPE d) { \
257 return Angle(static_cast<double>(a) OP d); \
260 inline const Angle operator OP(TYPE d, Angle const a) { \
261 return Angle(d OP static_cast<double>(a)); \
275 return Angle(static_cast<double>(a)/d);
279 return Angle(static_cast<double>(a)/d);
307 BOOST_STATIC_ASSERT_MSG(std::numeric_limits<T>::is_specialized,
308 "Only numeric types may be converted to Angles using degrees/radians!");
319 #endif // if !defined(LSST_AFW_GEOM_ANGLE_H)
double toUnitSphereDistanceSquared() const
const Angle operator/(Angle const a, int d)
double degToRad(double x)
double asArcminutes() const
double asAngularUnits(AngleUnit const &units) const
AngleUnit const radians
constant with units of radians
std::ostream & operator<<(std::ostream &os, lsst::afw::geom::AffineTransform const &transform)
double asArcseconds() const
A class used to convert scalar POD types such as double to Angle.
Angle(Angle const &other)
double radToDeg(double x)
void wrapNear(Angle const &refAng)
const Angle operator*(Angle const a, Angle const d)
double radToArcsec(double x)
static Angle fromUnitSphereDistanceSquared(double d2)
bool operator==(AngleUnit const &rhs) const
bool isAngle(T)
Allow a user to check if they have an angle (yes; they could do this themselves via trivial TMP) ...
Angle(double val, AngleUnit units=radians)
lsst::afw::geom::Angle Angle
AngleUnit const arcminutes
AngleUnit const arcseconds
double arcsecToRad(double x)
double radToMas(double x)
double masToRad(double x)
double const PI
The ratio of a circle's circumference to diameter.
friend const Angle operator*(T lhs, AngleUnit const rhs)
Use AngleUnit to convert a POD (e.g. int, double) to an Angle; e.g. 180*afwGeomdegrees.
#define ANGLE_OPUP_TYPE(OP, TYPE)
#define ANGLE_OP_TYPE(OP, TYPE)