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

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 to_string (int decimals=3) const
 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::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 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::Validating
 Validating ()
 dummy constructor;
Protected Attributes inherited from supernovas::Validating
bool _valid = false
 the state variable.

Detailed Description

A scalar coordinate or distance between two points in space.

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);
static constexpr double pc
[m] 1 kilometer in meters
Definition supernovas.h:122
Parameters
meters[m] The initializing value.
See also
zero(), at_Gpc()

References supernovas::Validating::_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::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.

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::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
parallaxThe parallax angle, which defines the distance
Returns
a distance instance corresponding to the specified parallax angle
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::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()

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::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::Unit::lyr.

◆ m()

◆ 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::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
dtthe 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::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::Unit::pc.

Referenced by parallax(), and to_string().

◆ to_string()

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

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.

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

Referenced by supernovas::CatalogEntry::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.

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.