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

A scalar coordinate or distance between two points in space. More...

`#include <supernovas.h>`

Inheritance diagram for supernovas::Coordinate:

## Public Member Functions

| Coordinate (double meters)
| Instantiates a distance (signed scalar separation along some direction) with the specified value in meters.
Coordinate | abs () const
| Returns the absolute value of this distance.
double | au () const
| Returns the distance in astronomical units.
double | Gpc () const
| Returns the distance in gigaparsecs.
double | km () const
| Returns the distance in kilometers.
double | kpc () const
| Returns the distance in kiloparsecs.
double | lyr () const
| Returns the distance in lightyears.
double | m () const
| Returns the distance in meters.
double | Mpc () const
| Returns the distance in megaparsecs.
ScalarVelocity | operator/ (const Interval &dt) const
| Returns the scalar velocity that is equal to this coordinate travelled under the specified time interval.
Angle | parallax () const
| Returns the parallax angle that corresponds to this distance instance.
double | pc () const
| Returns the distance in parsecs.
std::string | SI_unit () const override
std::string | to_string (int decimals=3) const override
| Returns a string representation of this distance using the specified number of significant figures and a best matched distance unit, e.g.
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 Coordinate & | at_Gpc ()
| Returns a standard distance of 1 Gpc.
static Coordinate | from_parallax (const Angle &parallax)
| Returns a new distance instance corresponding to a parallax angle.
static const Coordinate & | undefined ()
| Returns a reference to a static instance of an undefined / invalid coordinate.
static const Coordinate & | zero ()
| Returns a standard zero distance.

## 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 scalar coordinate or distance between two points in space.

Since
  1.6

See also
  Position

## Constructor & Destructor Documentation

## Coordinate()

supernovas::Coordinate::Coordinate | ( | double | meters | ) |

explicit

Instantiates a distance (signed scalar separation along some direction) with the specified value in meters.

You may use Unit to convert other distance measures to meters. For example, to set a distance of 12.4 parsecs, you might simply write:

Coordinate d(12.4 * Unit::pc);
supernovas::Unit::pc
static constexpr double pc
[m] 1 parsec in meters
Definition supernovas.h:136

Parameters

  meters | [m] The initializing value.

See also
  zero(), at_Gpc()

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

## Member Function Documentation

## abs()

Coordinate supernovas::Coordinate::abs | ( |  | ) | const

Returns the absolute value of this distance.

Returns
  the absolute value (length or distance) for this coordinate, as a coordinate itself.

References supernovas::Scalar::_value, and supernovas::Validating::is_valid().

## at_Gpc()

const Coordinate & supernovas::Coordinate::at_Gpc | ( |  | ) |

static

Returns a standard distance of 1 Gpc.

Historically NOVAS placed sidereal source at 1 Gpc distance if the distance was not specified otherwise. SuperNOVAS follows that, and so this static method can be used to obtain a persistent reference to a 1 Gpc instance.

Returns
  A reference to a persistent standard 1 Gpc distance instance.

Since
  1.6

References supernovas::Unit::Gpc.

## au()

double supernovas::Coordinate::au | ( |  | ) | const

Returns the distance in astronomical units.

Returns
  [AU] the distance in astronomical units.

See also
  m(), km(), lyr(), pc(), kpc(), Mpc(), Gpc()

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

Referenced by to_string().

## from_parallax()

Coordinate supernovas::Coordinate::from_parallax | ( | const Angle & | parallax | ) |

static

Returns a new distance instance corresponding to a parallax angle.

Parameters

  parallax | The parallax angle, which defines the distance

Returns
  a distance instance corresponding to the specified parallax angle

Since
  1.6

See also
  parallax()

References supernovas::Validating::is_valid(), parallax(), and supernovas::Unit::pc.

## Gpc()

double supernovas::Coordinate::Gpc | ( |  | ) | const

Returns the distance in gigaparsecs.

Returns
  [Gpc] the distance in gigaparsecs.

See also
  m(), km(), au(), lyr(), pc(), kpc(), Mpc()

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

Referenced by to_string().

## km()

double supernovas::Coordinate::km | ( |  | ) | const

Returns the distance in kilometers.

Returns
  [km] the distance in kilometers.

See also
  m(), au(), lyr(), pc(), kpc(), Mpc(), Gpc()

References supernovas::Scalar::_value.

Referenced by to_string().

## kpc()

double supernovas::Coordinate::kpc | ( |  | ) | const

Returns the distance in kiloparsecs.

Returns
  [kpc] the distance in kiloparsecs.

See also
  m(), km(), au(), lyr(), pc(), Mpc(), Gpc()

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

Referenced by to_string().

## lyr()

double supernovas::Coordinate::lyr | ( |  | ) | const

Returns the distance in lightyears.

Returns
  [lyr] the distance in lightyears.

See also
  m(), km(), au(), pc(), kpc(), Mpc(), Gpc()

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

## m()

double supernovas::Coordinate::m | ( |  | ) | const

Returns the distance in meters.

Returns
  [m] the distance in meters.

See also
  km(), au(), lyr(), pc(), kpc(), Mpc(), Gpc()

References supernovas::Scalar::_value.

Referenced by supernovas::CatalogEntry::distance(), supernovas::Site::equals(), supernovas::Orbital::from_mean_motion(), supernovas::AstrometricPosition::obs_time(), supernovas::OrbitalSystem::orbit(), supernovas::Horizontal::to_apparent(), and supernovas::Spherical::xyz().

## Mpc()

double supernovas::Coordinate::Mpc | ( |  | ) | const

Returns the distance in megaparsecs.

Returns
  [Mpc] the distance in megaparsecs.

See also
  m(), km(), au(), lyr(), pc(), kpc(), Gpc()

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

Referenced by to_string().

## operator/()

ScalarVelocity supernovas::Coordinate::operator/ | ( | const Interval & | dt | ) | const

Returns the scalar velocity that is equal to this coordinate travelled under the specified time interval.

Parameters

  dt | the time interval on the right-hand-side of '/'.

Returns
  scalar velocity v = x / dt, where x is this coordinate.

See also
  Position::operator/()

References supernovas::Scalar::_value, supernovas::Validating::is_valid(), and supernovas::Interval::seconds().

## parallax()

Angle supernovas::Coordinate::parallax | ( |  | ) | const

Returns the parallax angle that corresponds to this distance instance.

Returns
  the parallax angle corresponding to this distance.

See also
  from_parallax()

References supernovas::Unit::arcsec, supernovas::Validating::is_valid(), and pc().

Referenced by from_parallax().

## pc()

double supernovas::Coordinate::pc | ( |  | ) | const

Returns the distance in parsecs.

Returns
  [pc] the distance in parsecs.

See also
  m(), km(), au(), lyr(), kpc(), Mpc(), Gpc()

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

Referenced by parallax(), and to_string().

## SI_unit()

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

override virtual

Implements supernovas::Scalar.

## to_string()

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

override virtual

Returns a string representation of this distance using the specified number of significant figures and a best matched distance unit, e.g.

"10.96 km", or 305.6 pc" etc.

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

Since
  1.6

Reimplemented from supernovas::Scalar.

References supernovas::Scalar::_value, au(), supernovas::Unit::au, Gpc(), km(), kpc(), Mpc(), pc(), and supernovas::Unit::pc.

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

## undefined()

const Coordinate & supernovas::Coordinate::undefined | ( |  | ) |

static

Returns a reference to a static instance of an undefined / invalid coordinate.

Returns
  a reference to a standard instance of an undefined coordinate.

Since
  1.6

Referenced by supernovas::Track< CoordType >::distance_at(), and supernovas::Planet::mean_radius().

## zero()

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

static

Returns a standard zero distance.

Returns
  A reference to a persistent standard zero distance instance.

Since
  1.6