1 #if !defined(LSST_AFW_GEOM_ANGLE_H)
2 #define LSST_AFW_GEOM_ANGLE_H
6 #include <boost/math/constants/constants.hpp>
9 namespace lsst {
namespace afw {
namespace geom {
15 #pragma clang diagnostic push
16 #pragma clang diagnostic ignored "-Wunused-variable"
17 double const PI = boost::math::constants::pi<double>();
18 double const TWOPI = boost::math::constants::pi<double>() * 2.0;
19 double const HALFPI = boost::math::constants::pi<double>() * 0.5;
20 double const ONE_OVER_PI = 1.0 / boost::math::constants::pi<double>();
21 double const SQRTPI = sqrt(boost::math::constants::pi<double>());
22 double const INVSQRTPI = 1.0/sqrt(boost::math::constants::pi<double>());
23 double const ROOT2 = boost::math::constants::root_two<double>();
24 #pragma clang diagnostic pop
35 return x * 3600. * 180. /
PI;
38 return x * 1000. * 3600. * 180. /
PI;
41 return (x / 3600.) *
PI / 180.;
44 return (x / (1000. * 3600.)) *
PI / 180.;
51 #if 0 && !defined(M_PI) // a good idea, but with ramifications
52 # define M_PI ::lsst::afw::geom::PI
82 return (_val == rhs.
_val);
112 operator double()
const {
return _val; }
134 return (std::acos(1. - d2/2.)) *
radians;
196 if (
_val - refAngRad >=
PI) {
200 if (
_val - refAngRad < -
PI) {
201 _val -=
_val * 2.0 * std::numeric_limits<double>::epsilon();
206 #define ANGLE_OPUP_TYPE(OP, TYPE) \
207 Angle& operator OP(TYPE const& d) { \
219 #undef ANGLE_OPUP_TYPE
221 #define ANGLE_COMP(OP) \
222 bool operator OP ( const Angle& rhs ) { \
223 return _val OP rhs._val; \
249 #define ANGLE_OP(OP) \
250 inline const Angle operator OP(Angle const a, Angle const d) { \
251 return Angle(static_cast<double>(a) OP static_cast<double>(d)); \
254 #define ANGLE_OP_TYPE(OP, TYPE) \
255 inline const Angle operator OP(Angle const a, TYPE d) { \
256 return Angle(static_cast<double>(a) OP d); \
259 inline const Angle operator OP(TYPE d, Angle const a) { \
260 return Angle(d OP static_cast<double>(a)); \
274 return Angle(static_cast<double>(a)/d);
278 return Angle(static_cast<double>(a)/d);
306 static_assert(std::numeric_limits<T>::is_specialized,
307 "Only numeric types may be converted to Angles using degrees/radians!");
318 #endif // if !defined(LSST_AFW_GEOM_ANGLE_H)
double asArcseconds() const
Return an Angle's value as a double in arcseconds.
const Angle operator/(Angle const a, int d)
double degToRad(double x)
Angle(Angle const &other)
Copy constructor.
AngleUnit const radians
constant with units of radians
std::ostream & operator<<(std::ostream &os, lsst::afw::geom::AffineTransform const &transform)
void wrapCtr()
Wrap this angle to the range [-pi, pi)
A class used to convert scalar POD types such as double to Angle.
double radToDeg(double x)
const Angle operator*(Angle const a, Angle const d)
A class representing an Angle.
double radToArcsec(double x)
double asAngularUnits(AngleUnit const &units) const
Convert an Angle to a float in radians.
double toUnitSphereDistanceSquared() const
bool isAngle(T)
Allow a user to check if they have an angle (yes; they could do this themselves via trivial TMP) ...
void wrapNear(Angle const &refAng)
Wrap this angle such that pi <= this - refAng < pi.
lsst::afw::geom::Angle Angle
AngleUnit const arcminutes
Angle(double val, AngleUnit units=radians)
Construct an Angle with the specified value (interpreted in the given units)
AngleUnit const arcseconds
double arcsecToRad(double x)
double asRadians() const
Return an Angle's value as a double in radians.
double radToMas(double x)
double masToRad(double x)
double asDegrees() const
Return an Angle's value as a double in degrees.
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.
static Angle fromUnitSphereDistanceSquared(double d2)
void wrap()
Wraps this angle to the range [0, 2 pi)
#define ANGLE_OPUP_TYPE(OP, TYPE)
double asHours() const
Return an Angle's value as a double in hours.
double asArcminutes() const
Return an Angle's value as a double in arcminutes.
#define ANGLE_OP_TYPE(OP, TYPE)
bool operator==(AngleUnit const &rhs) const