SuperNOVAS C++ API v1.6
High-precision C/C++ astrometry library
Loading...
Searching...
No Matches
supernovas::Angle Class Reference

A representation of a regularized angle, which can be expressed in various commonly used angular units as needed. More...

#include <supernovas.h>

Inheritance diagram for supernovas::Angle:

Public Member Functions

 Angle (const std::string &str)
 Instantiates an angle from its string representation, either as decimal degrees or as [-]DDD:MM:SS.SSS.
 Angle (double radians)
 Instantiates a new angle with the specified value in radians.
virtual ~Angle ()
double arcmin () const
 Returns the angle in arc minutes.
double arcsec () const
 Returns the angle in arc seconds.
double deg () const
 Returns the angle in degrees.
bool equals (const Angle &angle, double precision=Unit::uas) const
 Checks if this angle instance equals another within the specified absolute precision.
double fraction () const
 Returns the angle as a fraction of the circle.
double mas () const
 Returns the angle in milliarcseconds.
bool operator!= (const Angle &angle) const
 Checks if this angle instance differs from another by more than 1 μas.
virtual Angle operator+ (const Angle &r) const
 Returns a new angle that is the sum of this angle and the specified other angle.
virtual Angle operator- (const Angle &r) const
 Returns a new angle that is the difference of this angle and the specified other angle.
bool operator== (const Angle &angle) const
 Checks if this angle instance equals another within the 1 μas.
double rad () const
 Returns the angle in radians.
virtual std::string to_string (enum novas_separator_type separator=NOVAS_SEP_UNITS_AND_SPACES, int decimals=3) const
 Provides a DDD:MM:SS.SSS representation of the angle with the specified separators and decimal places for the arc seconds.
double uas () const
 Returns the angle in microarcseconds.
Public Member Functions inherited from supernovas::Validating
bool is_valid () const
 Returns the previously set 'valid' stae of the implementing instance.
 operator bool () const
 Objects that implement Validating can be used in conditionals directly, without explicitly calling is_valid().

Static Public Member Functions

static const Angle & undefined ()
 Returns a reference to a statically defined standard invalid angle.

Static Public Attributes

static constexpr int east = 1
 East direction sign, e.g 19.5 * Unit::deg * Angle::east for 19.5 deg East.
static constexpr int north = 1
 North direction sign, e.g 33.4 * Unit::deg * Angle::north for 33.4 deg North.
static constexpr int south = -1
 South direction sign, e.g 90.0 * Unit::deg * Angle::south for the South pole.
static constexpr int west = -1
 West direction sign, e.g 155.1 * Unit::deg * Angle::west for 155.1 deg West.

Protected Attributes

double _rad
 [rad] stored angle value, usually [-π:π), but can be different for subclasses.
Protected Attributes inherited from supernovas::Validating
bool _valid = false
 the state variable.

Additional Inherited Members

Protected Member Functions inherited from supernovas::Validating
 Validating ()
 dummy constructor;

Detailed Description

A representation of a regularized angle, which can be expressed in various commonly used angular units as needed.

It can also be used to instantiate angles from decimal or [+]DDD:MM:SS.SSS string representations of the angle in degrees.

See also
TimeAngle

Constructor & Destructor Documentation

◆ ~Angle()

virtual supernovas::Angle::~Angle ( )
inlinevirtual

◆ Angle() [1/2]

supernovas::Angle::Angle ( double radians)
explicit

Instantiates a new angle with the specified value in radians.

You can use the Unit class to convert angles expressed in other units to radians. For example, to set 15.0 degrees, you might write:

Angle a(15.0 * Unit::deg);
static constexpr double deg
[rad] 1 hour of angle in radians on the 24h circle.
Definition supernovas.h:151
Parameters
radians[rad] the initializing value.
See also
TimeAngle, Unit

References _rad, and supernovas::Validating::_valid.

◆ Angle() [2/2]

supernovas::Angle::Angle ( const std::string & str)
explicit

Instantiates an angle from its string representation, either as decimal degrees or as [-]DDD:MM:SS.SSS.

Other than colons, the degrees, minutes, and seconds components may be separated by the symbols d, m, or white spaces of cobination of the above. To learn more about what exact representations are supported see novas:novas_str_degrees().

Parameters
stra string specifying an angle either as decimal degrees or as DDD:MM:SS.SSS and variants thereof.
See also
novas:novas_str_degrees()

References _rad, supernovas::Validating::_valid, supernovas::Unit::deg, and novas_str_degrees().

Member Function Documentation

◆ arcmin()

double supernovas::Angle::arcmin ( ) const

Returns the angle in arc minutes.

Returns
[arcmin] the angle in arc minutes, usually in the [-10800:10800) range, although subclasses may support different ranges for the returned value.
See also
rad(), deg(), arcsec(), mas(), uas()

References supernovas::Unit::arcmin, and rad().

◆ arcsec()

double supernovas::Angle::arcsec ( ) const

Returns the angle in arc seconds.

Returns
[arcsec] the angle in arc seconds, usually in the [-648000:648000) range, although subclasses may support different ranges for the returned value.
See also
rad(), deg(), arcmin(), mas(), uas()

References supernovas::Unit::arcsec, and rad().

◆ deg()

double supernovas::Angle::deg ( ) const

Returns the angle in degrees.

Returns
[degrees] the angle in degrees, usually in the [-180:180) range, although subclasses may support different ranges for the returned value.
See also
rad(), arcmin(), arcsec(), mas(), uas()

References supernovas::Unit::deg, and rad().

Referenced by supernovas::CatalogEntry::CatalogEntry(), supernovas::Spherical::distance_to(), supernovas::Time::lst(), supernovas::Time::next_moon_phase(), supernovas::Source::rises_above(), supernovas::Source::sets_below(), supernovas::Equatorial::to_ecliptic(), supernovas::Equatorial::to_galactic(), and to_string().

◆ equals()

bool supernovas::Angle::equals ( const Angle & angle,
double precision = Unit::uas ) const

Checks if this angle instance equals another within the specified absolute precision.

Parameters
angleanother angle
precision[rad] the abolute precision to use when testing for equality. If the two angles are closer on the 2π circle to each other than this precision, then they are consideredc equal, otherwise not.
Returns
true if the two angles match within the specified precision, or else false.
See also
operator==(), operator!=()

References _rad, and supernovas::Constant::two_pi.

Referenced by operator!=(), and operator==().

◆ fraction()

double supernovas::Angle::fraction ( ) const

Returns the angle as a fraction of the circle.

Returns
the angle as a fraction of the circle, usually in the [0:1) range.

References _rad, and supernovas::Constant::two_pi.

◆ mas()

double supernovas::Angle::mas ( ) const

Returns the angle in milliarcseconds.

Returns
[mas] the angle in milliarcseconds, usually in the [-6.48e8:6.48e8) range, although subclasses may support different ranges for the returned value.
See also
rad(), deg(), arcmin(), arcsec(), uas()

References supernovas::Unit::mas, and rad().

◆ operator!=()

bool supernovas::Angle::operator!= ( const Angle & angle) const

Checks if this angle instance differs from another by more than 1 μas.

Parameters
angleanother angle
Returns
true if the two angles differ by more than 1 μas, or else false.
See also
equals(), operator==()

References equals().

◆ operator+()

Angle supernovas::Angle::operator+ ( const Angle & r) const
virtual

Returns a new angle that is the sum of this angle and the specified other angle.

Parameters
rthe other angle on the right-hand-side.
Returns
the sum of this angle and the argument, as a new angle.
See also
operator-()

Reimplemented in supernovas::TimeAngle.

References supernovas::Validating::is_valid(), and rad().

Referenced by supernovas::TimeAngle::operator+().

◆ operator-()

Angle supernovas::Angle::operator- ( const Angle & r) const
virtual

Returns a new angle that is the difference of this angle and the specified other angle.

Parameters
rthe other angle on the right-hand-side.
Returns
the difference of this angle and the argument, as a new angle.
See also
operator+()

Reimplemented in supernovas::TimeAngle.

References supernovas::Validating::is_valid(), and rad().

Referenced by supernovas::TimeAngle::operator-().

◆ operator==()

bool supernovas::Angle::operator== ( const Angle & angle) const

Checks if this angle instance equals another within the 1 μas.

Parameters
angleanother angle
Returns
true if the two angles match within 1 μas, or else false.
See also
equals(), operator!=()

References equals().

◆ rad()

◆ to_string()

std::string supernovas::Angle::to_string ( enum novas_separator_type separator = NOVAS_SEP_UNITS_AND_SPACES,
int decimals = 3 ) const
virtual

Provides a DDD:MM:SS.SSS representation of the angle with the specified separators and decimal places for the arc seconds.

Parameters
separatorthe type of separators / unit markers used to distinguish the degree, minute, and second components.
decimals[0:9] the number of decimal places to print for the arc seconds component.
Returns
the strung representation of this angle in degrees.
See also
TimeAngle::to_string()

Reimplemented in supernovas::TimeAngle.

References deg(), and novas_print_dms().

Referenced by supernovas::CatalogSource::to_string(), supernovas::Equatorial::to_string(), supernovas::Site::to_string(), and supernovas::Spherical::to_string().

◆ uas()

double supernovas::Angle::uas ( ) const

Returns the angle in microarcseconds.

Returns
[μas] the angle in microarcseconds, usually in the [-6.48e11:6.48e11) range, although subclasses may support different ranges for the returned value.
See also
rad(), deg(), arcmin(), arcsec(), mas()

References rad(), and supernovas::Unit::uas.

◆ undefined()

const Angle & supernovas::Angle::undefined ( )
static

Returns a reference to a statically defined standard invalid angle.

Sunch invalid angles may be used inside any object that is invalid itself.

Returns
a reference to a static standard invalid angle.

Referenced by supernovas::Track< CoordType >::latitude_at(), and supernovas::Track< CoordType >::longitude_at().

Member Data Documentation

◆ _rad

double supernovas::Angle::_rad
protected

[rad] stored angle value, usually [-π:π), but can be different for subclasses.

Referenced by Angle(), Angle(), supernovas::TimeAngle::TimeAngle(), equals(), fraction(), supernovas::TimeAngle::hours(), and rad().

◆ east

int supernovas::Angle::east = 1
staticconstexpr

East direction sign, e.g 19.5 * Unit::deg * Angle::east for 19.5 deg East.

◆ north

int supernovas::Angle::north = 1
staticconstexpr

North direction sign, e.g 33.4 * Unit::deg * Angle::north for 33.4 deg North.

◆ south

int supernovas::Angle::south = -1
staticconstexpr

South direction sign, e.g 90.0 * Unit::deg * Angle::south for the South pole.

◆ west

int supernovas::Angle::west = -1
staticconstexpr

West direction sign, e.g 155.1 * Unit::deg * Angle::west for 155.1 deg West.