30#ifndef LSST_SPHGEOM_ANGLE_H_
31#define LSST_SPHGEOM_ANGLE_H_
53 return Angle(std::numeric_limits<double>::quiet_NaN());
56 static Angle fromDegrees(
double a) {
return Angle(a * RAD_PER_DEG); }
58 static Angle fromRadians(
double a) {
return Angle(a); }
64 explicit Angle(
double a) : _rad(a) {}
67 bool operator==(
Angle const & a)
const {
return _rad == a._rad; }
68 bool operator!=(
Angle const & a)
const {
return _rad != a._rad; }
69 bool operator<(
Angle const & a)
const {
return _rad < a._rad; }
70 bool operator>(
Angle const & a)
const {
return _rad > a._rad; }
71 bool operator<=(
Angle const & a)
const {
return _rad <= a._rad; }
72 bool operator>=(
Angle const & a)
const {
return _rad >= a._rad; }
75 Angle operator-()
const {
return Angle(-_rad); }
78 Angle operator*(
double a)
const {
return Angle(_rad * a); }
79 Angle operator/(
double a)
const {
return Angle(_rad / a); }
80 double operator/(
Angle const & a)
const {
return _rad / a._rad; }
83 Angle & operator+=(
Angle const & a) { *
this = *
this + a;
return *
this; }
84 Angle & operator-=(
Angle const & a) { *
this = *
this - a;
return *
this; }
85 Angle & operator*=(
double a) { *
this = *
this * a;
return *
this; }
86 Angle & operator/=(
double a) { *
this = *
this / a;
return *
this; }
89 double asDegrees()
const {
return _rad * DEG_PER_RAD; }
95 bool isNormalized()
const {
return _rad >= 0.0 && _rad <= 2.0 * PI; }
98 bool isNan()
const {
return std::isnan(_rad); }
105inline Angle operator*(
double a, Angle
const & b) {
return b * a; }
107std::ostream & operator<<(std::ostream &, Angle
const &);
109inline double sin(Angle
const & a) {
return std::sin(a.asRadians()); }
110inline double cos(Angle
const & a) {
return std::cos(a.asRadians()); }
111inline double tan(Angle
const & a) {
return std::tan(a.asRadians()); }
113inline Angle abs(Angle
const & a) {
return Angle(std::fabs(a.asRadians())); }
bool isNan() const
isNan returns true if the angle value is NaN.
Definition Angle.h:98
bool isNormalized() const
isNormalized returns true if this angle lies in the range [0, 2π).
Definition Angle.h:95
Angle(double a)
This constructor creates an Angle with the given value in radians.
Definition Angle.h:64
Angle()
This constructor creates an Angle with a value of zero.
Definition Angle.h:61
double asDegrees() const
asDegrees returns the value of this angle in units of degrees.
Definition Angle.h:89
double asRadians() const
asRadians returns the value of this angle in units of radians.
Definition Angle.h:92
This file contains common constants.