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

A representation of a regularized angle, which can also be represented as a time value in the 0 to 24h range. More...

#include <supernovas.h>

Inheritance diagram for supernovas::TimeAngle:

Public Member Functions

 TimeAngle (const Angle &angle)
 Instantiates an angle, to be represented as time on a 24 hour interval, from an angle instance.
 TimeAngle (const std::string &str)
 Instantiates an angle, to be represented as time on a 24 hour interval, from a HMS or decimal string representation of time.
 TimeAngle (double radians)
 Instantiates an angle, to be represented as time on a 24 hour interval, from a canonical angle in radians.
double hours () const
 Returns this angle as hours on a 24h interval.
double minutes () const
 Returns this angle as minutes inside a 24h interval.
Angle operator+ (const Angle &r) const override
 Returns a new angle that is the sum of this angle and the specified other angle.
TimeAngle operator+ (const Interval &other) const
 Returns a new time-angle that is the sum of this time-angle and the specified time interval.
TimeAngle operator+ (const TimeAngle &r) const
 Returns a new time-angle that is the sum of this rime-angle and the specified other time-angle.
Angle operator- (const Angle &r) const override
 Returns a new angle that is the difference of this angle and the specified other angle.
TimeAngle operator- (const Interval &other) const
 Returns a new time-angle that is the difference of this time-angle and the specified time interval.
TimeAngle operator- (const TimeAngle &r) const
 Returns a new time-angle that is the difference of this time-angle and the specified other time-angle.
double seconds () const
 Returns this angle as seconds on a 24h interval.
std::string to_string (enum novas_separator_type separator=NOVAS_SEP_UNITS_AND_SPACES, int decimals=3) const override
 Provides a DDD:MM:SS.SSS representation of the angle with the specified separators and decimal places for the arc seconds.
Public Member Functions inherited from supernovas::Angle
 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.
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.
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 TimeAngle hours (double value)
 Returns a new time-angle given the specified time value in hours.
static TimeAngle minutes (double value)
 Returns a new time-angle given the specified time value in minutes.
static const TimeAnglenoon ()
 Returns a reference to a statically defined time angle corresponding to noon (12h).
static TimeAngle seconds (double value)
 Returns a new time-angle given the specified time value in seconds.
static const TimeAnglezero ()
 Returns a reference to a statically defined time-angle that represents a zero angle.
Static Public Member Functions inherited from supernovas::Angle
static const Angle & undefined ()
 Returns a reference to a statically defined standard invalid angle.

Additional Inherited Members

Static Public Attributes inherited from supernovas::Angle
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 Member Functions inherited from supernovas::Validating
 Validating ()
 dummy constructor;
Protected Attributes inherited from supernovas::Angle
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.

Detailed Description

A representation of a regularized angle, which can also be represented as a time value in the 0 to 24h range.

It can be expressed both in terms various commonly used angular units, or in terms of time units, as needed. It may also be used to instantiate time-angles from decimal or from HH:MM:SS.SSS string representations of time in hours.

See also
Time, Interval

Constructor & Destructor Documentation

◆ TimeAngle() [1/3]

supernovas::TimeAngle::TimeAngle ( double radians)
explicit

Instantiates an angle, to be represented as time on a 24 hour interval, from a canonical angle in radians.

Parameters
radians[rad] the angle in radians

References supernovas::Angle::_rad, and TWOPI.

Referenced by hours(), minutes(), noon(), operator+(), operator+(), operator-(), operator-(), seconds(), and zero().

◆ TimeAngle() [2/3]

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

Instantiates an angle, to be represented as time on a 24 hour interval, from a HMS or decimal string representation of time.

Parameters
strA decimal or HMS representation of time, using spaces, colons, and/or the letters h, m (and optionally s) as separators.

References novas_str_hours().

◆ TimeAngle() [3/3]

supernovas::TimeAngle::TimeAngle ( const Angle & angle)
explicit

Instantiates an angle, to be represented as time on a 24 hour interval, from an angle instance.

Parameters
anglean angle to initialize with.

Member Function Documentation

◆ hours() [1/2]

double supernovas::TimeAngle::hours ( ) const

◆ hours() [2/2]

TimeAngle supernovas::TimeAngle::hours ( double value)
static

Returns a new time-angle given the specified time value in hours.

The input time may be any real value, but the returned time angle will be restricted to a single 24 hour interval.

Parameters
value[h] the angle defined as hours of time.
Returns
a new time-angle with the specified time defining the angle.
See also
minutes(), seconds()

References TimeAngle(), supernovas::Unit::hour_angle, and supernovas::Validating::is_valid().

◆ minutes() [1/2]

double supernovas::TimeAngle::minutes ( ) const

Returns this angle as minutes inside a 24h interval.

Returns
[m] the angle as minutes of time on the [0.0:1440.0) interval.
See also
hours(), seconds(), Angle::rad(), Angle::deg(), Angle::arcmin(), Angle::arcsec()

References hours().

◆ minutes() [2/2]

TimeAngle supernovas::TimeAngle::minutes ( double value)
static

Returns a new time-angle given the specified time value in minutes.

The input time may be any real value, but the returned time angle will be restricted to a single 24 hour interval.

Parameters
value[m] the angle defined as minutes of time.
Returns
a new time-angle with the specified time defining the angle.
See also
hours(), seconds()

References TimeAngle(), supernovas::Unit::hour_angle, and supernovas::Validating::is_valid().

◆ noon()

const TimeAngle & supernovas::TimeAngle::noon ( )
static

Returns a reference to a statically defined time angle corresponding to noon (12h).

Returns
a reference to the statically defined time-angle for noon (12h).

References TimeAngle(), and supernovas::Unit::hour_angle.

◆ operator+() [1/3]

Angle supernovas::TimeAngle::operator+ ( const Angle & r) const
overridevirtual

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 from supernovas::Angle.

References supernovas::Angle::operator+().

◆ operator+() [2/3]

TimeAngle supernovas::TimeAngle::operator+ ( const Interval & offset) const

Returns a new time-angle that is the sum of this time-angle and the specified time interval.

Parameters
offsetthe time interval on the right-hand-side.
Returns
the sum of this time-angle and the time interval, as a new time-angle.
See also
operator-()

References TimeAngle(), supernovas::Unit::hour_angle, supernovas::Interval::hours(), supernovas::Validating::is_valid(), and supernovas::Angle::rad().

◆ operator+() [3/3]

TimeAngle supernovas::TimeAngle::operator+ ( const TimeAngle & r) const

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

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

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

◆ operator-() [1/3]

Angle supernovas::TimeAngle::operator- ( const Angle & r) const
overridevirtual

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 from supernovas::Angle.

References supernovas::Angle::operator-().

◆ operator-() [2/3]

TimeAngle supernovas::TimeAngle::operator- ( const Interval & offset) const

Returns a new time-angle that is the difference of this time-angle and the specified time interval.

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

References TimeAngle(), supernovas::Unit::hour_angle, supernovas::Interval::hours(), supernovas::Validating::is_valid(), and supernovas::Angle::rad().

◆ operator-() [3/3]

TimeAngle supernovas::TimeAngle::operator- ( const TimeAngle & r) const

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

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

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

◆ seconds() [1/2]

double supernovas::TimeAngle::seconds ( ) const

Returns this angle as seconds on a 24h interval.

Returns
[s] the angle as seconds of time on the [0.0:86400.0) interval.
See also
hours(), minutes(), seconds(), Angle::rad(), Angle::deg(), Angle::arcmin(), Angle::arcsec()

References hours().

◆ seconds() [2/2]

TimeAngle supernovas::TimeAngle::seconds ( double value)
static

Returns a new time-angle given the specified time value in seconds.

The input time may be any real value, but the returned time angle will be restricted to a single 24 hour interval.

Parameters
value[s] the angle defined as seconds of time.
Returns
a new time-angle with the specified time defining the angle.
See also
hours(), minutes()

References TimeAngle(), supernovas::Unit::hour_angle, and supernovas::Validating::is_valid().

◆ to_string()

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

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.

Reimplemented from supernovas::Angle.

References hours(), and novas_print_hms().

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

◆ zero()

const TimeAngle & supernovas::TimeAngle::zero ( )
static

Returns a reference to a statically defined time-angle that represents a zero angle.

Returns
a reference to the statically defined zero angle.

References TimeAngle().