Loading...
Searching...
No Matches
supernovas::Interval Class Reference
Helpers and utilities

A signed time interval between two instants of time, in the astronomical timescale of choice. More...

`#include <supernovas.h>`

Inheritance diagram for supernovas::Interval:

## Public Member Functions

| Interval (double seconds, enum novas_timescale timescale=NOVAS_TT)
| Instantiates a new time interval with the specified time in seconds and a timescale (TT by default).
double | days () const
| Returns this time interval in days.
bool | equals (const Interval &interval, double precision=Unit::us) const
| Checks if this time interval is equal to the specified other time interval within the specified precision.
double | hours () const
| Returns this time interval in hours.
Interval | inv () const
| Returns the inverse of this time interval ie, its negated value.
double | julian_centuries () const
| Returns this time interval in Julian centuries.
double | julian_years () const
| Returns this time interval in Julian years.
double | milliseconds () const
| Returns this time interval in milliseconds.
double | minutes () const
| Returns this time interval in minutes.
bool | operator!= (const Interval &interval) const
| Checks if this time interval differs from the specified other time interval at the full double-precision.
Coordinate | operator* (const ScalarVelocity &v) const
| Returns the distance travelled in this time interval at the specified speed.
Position | operator* (const Velocity &v) const
| Returns the spatial vector travelled in this time interval at the specified velocity.
Interval | operator+ (const Interval &r) const
| Returns a new time interval that is the sum of this time interval and the specified other time interval.
Interval | operator- (const Interval &r) const
| Returns a new time interval that is the signed difference of this time interval and the specified other time interval.
bool | operator== (const Interval &interval) const
| Checks if this time interval is equal to the specified other time interval at the full double-precision.
double | seconds () const
| Returns this time interval in seconds.
std::string | SI_unit () const override
enum novas_timescale | timescale () const
| Returns the time scale in which this time interval was defined.
std::string | to_string (int decimals=3) const override
| Returns a string representation of this interval using the specified number of significant figures and a best matched time unit.
Interval | to_timescale (enum novas_timescale scale) const
| Returns a new time interval, which matches this time interval in the specified other timescale.
double | weeks () const
| Returns this time interval in weeks.
double | years () const
| Returns this time interval in calendar years.
Public Member Functions inherited from supernovas::Scalar
virtual | ~Scalar ()
bool | equals (const Scalar &other, double precision) const
| Checks if this scalar quantity is the same as another, within the specified precision.
double | SI_value () const
| The value of this scalar quantity in S.I.
Public Member Functions inherited from supernovas::Validating
bool | is_valid () const
| Returns the previously set 'valid' state 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 Interval & | zero ()
| Returns a reference to the zero time interval.

## Additional Inherited Members

Protected Member Functions inherited from supernovas::Scalar
| Scalar ()
| Instantiates a standard undefined (invalid) scalar quantity with NAN value.
| Scalar (double SI_value)
| Instantiates a scalar quantity with an initializing value in standard S.I.
Protected Member Functions inherited from supernovas::Validating
| Validating ()
| dummy constructor;
Protected Attributes inherited from supernovas::Scalar
double | _value
| The value in S.I. units.
Protected Attributes inherited from supernovas::Validating
bool | _valid = false
| the state variable.

## Detailed Description

A signed time interval between two instants of time, in the astronomical timescale of choice.

Since
  1.6

See also
  Time, TimeAngle

## Constructor & Destructor Documentation

## Interval()

supernovas::Interval::Interval | ( | double | seconds,
|  | enum novas_timescale | timescale = NOVAS_TT )

explicit

Instantiates a new time interval with the specified time in seconds and a timescale (TT by default).

Parameters

  seconds | [s] time span in seconds.
  timescale | (optional) timescale in which the interval was defined (default: novas:NOVAS_TT)

Since
  1.6

See also
  zero()

References supernovas::Scalar::Scalar(), supernovas::Validating::_valid, supernovas::Validating::is_valid(), NOVAS_TIMESCALES, seconds(), and timescale().

Referenced by equals(), inv(), operator!=(), operator+(), operator-(), operator==(), to_timescale(), and zero().

## Member Function Documentation

## days()

double supernovas::Interval::days | ( |  | ) | const

Returns this time interval in days.

Returns
  [day] the time interval

Since
  1.6

See also
  milliseconds(), seconds(), minutes(), hours(), weeks(), years(), julian_years(), julian_centuries()

References supernovas::Scalar::_value, and supernovas::Unit::day.

Referenced by supernovas::CalendarDate::operator+(), supernovas::CalendarDate::operator-(), and to_string().

## equals()

bool supernovas::Interval::equals | ( | const Interval & | interval,
|  | double | precision = Unit::us ) const

Checks if this time interval is equal to the specified other time interval within the specified precision.

The comparison is performed in Terrestrial Time (TT).

Parameters

  interval | the reference time interval.
  precision | [s] the precision used for checking equality.

Returns
  true if this time interval is equal to the reference time interval within the specified precision, or else false.

Since
  1.6

See also
  operator==(), operator!=()

References Interval().

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

## hours()

double supernovas::Interval::hours | ( |  | ) | const

Returns this time interval in hours.

Returns
  [h] the time interval

Since
  1.6

See also
  milliseconds(), seconds(), minutes(), days(), weeks(), years(), julian_years(), julian_centuries()

References supernovas::Scalar::_value, and supernovas::Unit::hour.

Referenced by supernovas::TimeAngle::operator+(), supernovas::TimeAngle::operator-(), and to_string().

## inv()

Interval supernovas::Interval::inv | ( |  | ) | const

Returns the inverse of this time interval ie, its negated value.

Returns
  a new time interval with the same absolute value, but negated.

Since
  1.6

References Interval(), and supernovas::Scalar::_value.

## julian_centuries()

double supernovas::Interval::julian_centuries | ( |  | ) | const

Returns this time interval in Julian centuries.

Returns
  [cy] the time interval

Since
  1.6

See also
  milliseconds(), seconds(), minutes(), hours(), days(), weeks(), years(), julian_years()

References supernovas::Scalar::_value, and supernovas::Unit::julian_century.

## julian_years()

double supernovas::Interval::julian_years | ( |  | ) | const

Returns this time interval in Julian years.

Returns
  [yr] the time interval

Since
  1.6

See also
  milliseconds(), seconds(), minutes(), hours(), days(), weeks(), years(), julian_centuries()

References supernovas::Scalar::_value, and supernovas::Unit::julian_year.

## milliseconds()

double supernovas::Interval::milliseconds | ( |  | ) | const

Returns this time interval in milliseconds.

Returns
  [ms] the time interval

Since
  1.6

See also
  seconds(), minutes(), hours(), days(), weeks(), years(), julian_years(), julian_centuries()

References supernovas::Scalar::_value, and supernovas::Unit::ms.

Referenced by to_string().

## minutes()

double supernovas::Interval::minutes | ( |  | ) | const

Returns this time interval in minutes.

Returns
  [min] the time interval

Since
  1.6

See also
  milliseconds(), seconds(), hours(), days(), weeks(), years(), julian_years(), julian_centuries()

References supernovas::Scalar::_value, and supernovas::Unit::min.

## operator!=()

bool supernovas::Interval::operator!= | ( | const Interval & | interval | ) | const

Checks if this time interval differs from the specified other time interval at the full double-precision.

The comparison is performed in Terrestrial Time (TT).

Parameters

  interval | the reference time interval.

Returns
  true if this time interval differs from the reference time interval, or else false.

Since
  1.6

See also
  equals(), operator==()

References Interval(), and equals().

## operator*() [1/2]

Coordinate supernovas::Interval::operator* | ( | const ScalarVelocity & | v | ) | const

Returns the distance travelled in this time interval at the specified speed.

Parameters

  v | speed value

Returns
  the distance travelled under this time interval at the specified speed.

Since
  1.6

References supernovas::Validating::is_valid(), and supernovas::ScalarVelocity::travel().

## operator*() [2/2]

Position supernovas::Interval::operator* | ( | const Velocity & | v | ) | const

Returns the spatial vector travelled in this time interval at the specified velocity.

Parameters

  v | speed value

Returns
  the statial vector travelled under this interval at the specified velocity.

Since
  1.6

References supernovas::Validating::is_valid(), and supernovas::Velocity::travel().

## operator+()

Interval supernovas::Interval::operator+ | ( | const Interval & | r | ) | const

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

Parameters

  r | the other time interval

Returns
  the sum of this time interval and the argument time interval.

Since
  1.6

See also
  operator-()

References Interval().

## operator-()

Interval supernovas::Interval::operator- | ( | const Interval & | r | ) | const

Returns a new time interval that is the signed difference of this time interval and the specified other time interval.

Parameters

  r | the other time interval

Returns
  the signed difference of this time interval and the argument time interval.

Since
  1.6

See also
  operator+()

References Interval().

## operator==()

bool supernovas::Interval::operator== | ( | const Interval & | interval | ) | const

Checks if this time interval is equal to the specified other time interval at the full double-precision.

The comparison is performed in Terrestrial Time (TT).

Parameters

  interval | the reference time interval.

Returns
  true if this time interval is equal to the reference time interval, or else false.

Since
  1.6

See also
  equals(), operator!=()

References Interval(), and equals().

## seconds()

double supernovas::Interval::seconds | ( |  | ) | const

Returns this time interval in seconds.

Returns
  [s] the time interval

Since
  1.6

See also
  Interval::milliseconds(), Interval::minutes(), Interval::hours(), Interval::days(), Interval::weeks(), Interval::years(), Interval::julian_years(), Interval::julian_centuries()

References supernovas::Scalar::_value.

Referenced by Interval(), supernovas::CalendarDate::equals(), supernovas::Equinox::equals(), supernovas::Time::equals(), supernovas::Source::equatorial_track(), supernovas::EOP::fetch_current(), supernovas::Time::from_mjd(), supernovas::Time::now(), supernovas::Time::operator+(), supernovas::Time::operator-(), supernovas::Coordinate::operator/(), supernovas::Position::operator/(), supernovas::OrbitalSystem::orbit(), supernovas::ScalarEvolution::rate(), supernovas::Time::shifted(), supernovas::CalendarDate::to_time(), supernovas::ScalarVelocity::travel(), supernovas::Velocity::travel(), and supernovas::ScalarEvolution::value().

## SI_unit()

std::string supernovas::Interval::SI_unit | ( |  | ) | const

override virtual

Implements supernovas::Scalar.

## timescale()

enum novas_timescale supernovas::Interval::timescale | ( |  | ) | const

Returns the time scale in which this time interval was defined.

Returns
  the time scale for this interval.

Since
  1.6

Referenced by Interval().

## to_string()

std::string supernovas::Interval::to_string | ( | int | decimals = 3 | ) | const

override virtual

Returns a string representation of this interval using the specified number of significant figures and a best matched time unit.

Returns
  A human readable string representation of the distance and a unit specifier.

Since
  1.6

Reimplemented from supernovas::Scalar.

References supernovas::Scalar::_value, supernovas::Unit::day, days(), supernovas::Unit::hour, hours(), milliseconds(), supernovas::Unit::ms, supernovas::Unit::ns, supernovas::Unit::s, supernovas::Unit::us, years(), and supernovas::Unit::yr.

Referenced by supernovas::Interferometric::to_string(), and supernovas::Orbital::to_string().

## to_timescale()

Interval supernovas::Interval::to_timescale | ( | enum novas_timescale | scale | ) | const

Returns a new time interval, which matches this time interval in the specified other timescale.

Parameters

  scale | the timescale of the returned equivalent interval.

Returns
  the equivalent time interval in the specified timescale

Since
  1.6

References Interval().

## weeks()

double supernovas::Interval::weeks | ( |  | ) | const

Returns this time interval in weeks.

Returns
  [wk] the time interval

Since
  1.6

See also
  milliseconds(), seconds(), minutes(), hours(), days(), years(), julian_years(), julian_centuries()

References supernovas::Scalar::_value, and supernovas::Unit::week.

## years()

double supernovas::Interval::years | ( |  | ) | const

Returns this time interval in calendar years.

Returns
  [yr] the time interval

Since
  1.6

See also
  milliseconds(), seconds(), minutes(), hours(), days(), weeks(), julian_years(), julian_centuries()

References supernovas::Scalar::_value, and supernovas::Unit::yr.

Referenced by to_string().

## zero()

const Interval & supernovas::Interval::zero | ( |  | ) |

static

Returns a reference to the zero time interval.

Returns
  a reference to a statically defined zero time interval.

Since
  1.6

References Interval().