LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
lsst.afw.geom::Angle Class Reference

#include <Angle.h>

Public Member Functions

 Angle (double val, AngleUnit units=radians)
 
 Angle ()
 
 Angle (Angle const &other)
 
 operator double () const
 
double asAngularUnits (AngleUnit const &units) const
 
double asRadians () const
 
double asDegrees () const
 
double asHours () const
 
double asArcminutes () const
 
double asArcseconds () const
 
double toUnitSphereDistanceSquared () const
 
void wrap ()
 
void wrapCtr ()
 
void wrapNear (Angle const &refAng)
 
Angleoperator*= (double const &d)
 
Angleoperator*= (int const &d)
 
Angleoperator+= (double const &d)
 
Angleoperator+= (int const &d)
 
Angleoperator-= (double const &d)
 
Angleoperator-= (int const &d)
 
bool operator== (const Angle &rhs)
 
bool operator!= (const Angle &rhs)
 
bool operator<= (const Angle &rhs)
 
bool operator>= (const Angle &rhs)
 
bool operator< (const Angle &rhs)
 
bool operator> (const Angle &rhs)
 

Static Public Member Functions

static Angle fromUnitSphereDistanceSquared (double d2)
 

Private Attributes

double _val
 

Friends

class AngleUnit
 

Detailed Description

A class representing an Angle

Angles may be manipulated like doubles, and automatically converted to doubles, but they may not be constructed from doubles without calling a constructor or multiplying by an AngleUnit

Definition at line 104 of file Angle.h.

Constructor & Destructor Documentation

lsst.afw.geom::Angle::Angle ( double  val,
AngleUnit  units = radians 
)
inlineexplicit

Construct an Angle with the specified value (interpreted in the given units)

Definition at line 108 of file Angle.h.

108 : _val(val*units._val) {}
ImageT val
Definition: CR.cc:154
lsst.afw.geom::Angle::Angle ( )
inline

Definition at line 109 of file Angle.h.

109 : _val(0) {}
lsst.afw.geom::Angle::Angle ( Angle const &  other)
inline

Copy constructor.

Definition at line 111 of file Angle.h.

111 : _val(other._val) {}

Member Function Documentation

double lsst.afw.geom::Angle::asAngularUnits ( AngleUnit const &  units) const
inline

Convert an Angle to a float in radians Return an Angle's value as a double in the specified units (i.e. afwGeom::degrees)

Definition at line 118 of file Angle.h.

118  {
119  return _val/units._val;
120  }
double lsst.afw.geom::Angle::asArcminutes ( ) const
inline

Return an Angle's value as a double in arcminutes

Definition at line 128 of file Angle.h.

128 { return asAngularUnits(arcminutes); }
double asAngularUnits(AngleUnit const &units) const
Definition: Angle.h:118
AngleUnit const arcminutes
Definition: Angle.h:94
double lsst.afw.geom::Angle::asArcseconds ( ) const
inline

Return an Angle's value as a double in arcseconds

Definition at line 130 of file Angle.h.

130 { return asAngularUnits(arcseconds); }
double asAngularUnits(AngleUnit const &units) const
Definition: Angle.h:118
AngleUnit const arcseconds
Definition: Angle.h:95
double lsst.afw.geom::Angle::asDegrees ( ) const
inline

Return an Angle's value as a double in degrees

Definition at line 124 of file Angle.h.

124 { return asAngularUnits(degrees); }
double asAngularUnits(AngleUnit const &units) const
Definition: Angle.h:118
AngleUnit const degrees
Definition: Angle.h:92
double lsst.afw.geom::Angle::asHours ( ) const
inline

Return an Angle's value as a double in hours

Definition at line 126 of file Angle.h.

126 { return asAngularUnits(hours); }
double asAngularUnits(AngleUnit const &units) const
Definition: Angle.h:118
AngleUnit const hours
Definition: Angle.h:93
double lsst.afw.geom::Angle::asRadians ( ) const
inline

Return an Angle's value as a double in radians

Definition at line 122 of file Angle.h.

122 { return asAngularUnits(radians); }
double asAngularUnits(AngleUnit const &units) const
Definition: Angle.h:118
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
static Angle lsst.afw.geom::Angle::fromUnitSphereDistanceSquared ( double  d2)
inlinestatic

Definition at line 134 of file Angle.h.

134  {
135  return (std::acos(1. - d2/2.)) * radians;
136  // == 2.0 * asin(0.5 * sqrt(d2))
137  }
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
lsst.afw.geom::Angle::operator double ( ) const
inline

Convert an Angle to a double in radians

Definition at line 113 of file Angle.h.

113 { return _val; }
bool lsst.afw.geom::Angle::operator!= ( const Angle rhs)
inline

Definition at line 228 of file Angle.h.

236 :
237  double _val;
Angle& lsst.afw.geom::Angle::operator*= ( double const &  d)
inline

Definition at line 213 of file Angle.h.

223 { \
Angle& lsst.afw.geom::Angle::operator*= ( int const &  d)
inline

Definition at line 214 of file Angle.h.

223 { \
Angle& lsst.afw.geom::Angle::operator+= ( double const &  d)
inline

Definition at line 215 of file Angle.h.

223 { \
Angle& lsst.afw.geom::Angle::operator+= ( int const &  d)
inline

Definition at line 216 of file Angle.h.

223 { \
Angle& lsst.afw.geom::Angle::operator-= ( double const &  d)
inline

Definition at line 217 of file Angle.h.

223 { \
Angle& lsst.afw.geom::Angle::operator-= ( int const &  d)
inline

Definition at line 218 of file Angle.h.

223 { \
bool lsst.afw.geom::Angle::operator< ( const Angle rhs)
inline

Definition at line 231 of file Angle.h.

236 :
237  double _val;
bool lsst.afw.geom::Angle::operator<= ( const Angle rhs)
inline

Definition at line 229 of file Angle.h.

236 :
237  double _val;
bool lsst.afw.geom::Angle::operator== ( const Angle rhs)
inline

Definition at line 227 of file Angle.h.

236 :
237  double _val;
bool lsst.afw.geom::Angle::operator> ( const Angle rhs)
inline

Definition at line 232 of file Angle.h.

236 :
237  double _val;
bool lsst.afw.geom::Angle::operator>= ( const Angle rhs)
inline

Definition at line 230 of file Angle.h.

236 :
237  double _val;
double lsst.afw.geom::Angle::toUnitSphereDistanceSquared ( ) const
inline

Definition at line 132 of file Angle.h.

132 { return 2. * (1. - std::cos(asRadians())); }
double asRadians() const
Definition: Angle.h:122
void lsst.afw.geom::Angle::wrap ( )
inline
    Wraps this angle to the range [0, 2 pi)

@warning The upper limit is only guaranteed for radians;
the upper limit may be slightly squishy for other units, due to roundoff errors.

Whether there are any violations is unknown; please update this comment if you can prove that the limits are or are not valid for all supported units.

Definition at line 146 of file Angle.h.

146  {
147  _val = std::fmod(_val, TWOPI);
148  // _val is now in the range (-TWOPI, TWOPI)
149  if (_val < 0.0)
150  _val += TWOPI;
151  // if _val is small enough, adding 2 pi gives 2 pi
152  if (_val >= TWOPI)
153  _val = 0.0;
154  }
double const TWOPI
Definition: Angle.h:19
void lsst.afw.geom::Angle::wrapCtr ( )
inline
Wrap this angle to the range [-pi, pi)
Warning
Exact limits are only guaranteed for radians; limits for other units may be slightly squishy, due to roundoff errors. Whether there are any violations is unknown; please update this comment if you can prove that the limits are or are not valid for all supported units.

Definition at line 162 of file Angle.h.

162  {
163  _val = std::fmod(_val, TWOPI);
164  // _val is now in the range [-TWOPI, TWOPI]
165  if (_val < -PI) {
166  _val += TWOPI;
167  if (_val >= PI) {
168  // handle roundoff error, however unlikely
169  _val = -PI;
170  }
171  } else if (_val >= PI) {
172  _val -= TWOPI;
173  if (_val < -PI) {
174  // handle roundoff error, however unlikely
175  _val = -PI;
176  }
177  }
178  }
double const TWOPI
Definition: Angle.h:19
double const PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:18
void lsst.afw.geom::Angle::wrapNear ( Angle const &  refAng)
inline
Wrap this angle such that pi <= this - refAng < pi
Warning
Exact limits are only guaranteed for radians; limits for other units may be slightly squishy due to roundoff errors. There are known violations that are demonstrated in testWrap in tests/angle.py.
Parameters
refAngreference angle to match

Definition at line 186 of file Angle.h.

188  {
189  // compute this = (this - refAng).wrapCtr() + refAng
190  // which is correct except for roundoff error at the edges
191  double refAngRad = refAng.asRadians();
192  *this -= refAng;
193  wrapCtr();
194  _val += refAngRad;
195 
196  // roundoff can cause slightly out-of-range values; fix those
197  if (_val - refAngRad >= PI) {
198  _val -= TWOPI;
199  }
200  // maximum relative roundoff error for subtraction is 2 epsilon
201  if (_val - refAngRad < -PI) {
202  _val -= _val * 2.0 * std::numeric_limits<double>::epsilon();
203  }
204  }
double const TWOPI
Definition: Angle.h:19
double const PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:18

Friends And Related Function Documentation

friend class AngleUnit
friend

Definition at line 105 of file Angle.h.

Member Data Documentation

double lsst.afw.geom::Angle::_val
private

Definition at line 237 of file Angle.h.


The documentation for this class was generated from the following file: