Loading...
Searching...
No Matches
supernovas::ScalarVelocity Class Reference
Spectroscopic applications

A scalar velocity (if signed) or speed (if unsigned). More...

`#include <supernovas.h>`

Inheritance diagram for supernovas::ScalarVelocity:

## Public Member Functions

| ScalarVelocity (double m_per_s)
| Instantiates a (signed) scalar velocity (speed) with the specified S.I.
ScalarVelocity | abs () const
| Returns the magnitude of this speed, as a unsigned speed.
double | au_per_day () const
| Returns this speed in AU/day.
double | beta () const
| Returns this speed (v) as β = v / c.
bool | equals (const ScalarVelocity &speed, const ScalarVelocity &tolerance) const
| Checks if this speed equals the specified other speed within the tolerance.
bool | equals (const ScalarVelocity &speed, double tolerance=Unit::mm/Unit::sec) const
| Checks if this speed equals the specified other speed within the tolerance.
double | Gamma () const
| Returns the relativistic boost parameter Γ for this speed (v) as Γ = &radic (1 - v2 / c2).
Velocity | in_direction (const Vector &direction) const
| Returns a 3-dimensional velocity vector corresponding to this speed along the specified direction.
double | km_per_s () const
| Returns this speed in km/s.
double | m_per_s () const
| Returns this speed in m/s.
bool | operator!= (const ScalarVelocity &speed) const
| Checks if this speed differs from the specified other speed, by more than 1 mm/s.
Coordinate | operator* (const Interval &time) const
| Returns the distance travelled at this speed under the specified time interval.
ScalarVelocity | operator+ (const ScalarVelocity &r) const
| Returns the signed scalar sum of this speed and the specified other speed, using the relativistic formula for addition.
ScalarVelocity | operator- (const ScalarVelocity &r) const
| Returns the signed scalar difference of this speed and the specified other speed, using the relativistic formula for addition.
bool | operator== (const ScalarVelocity &speed) const
| Checks if this speed equals the specified other speed within 1 mm/s.
ScalarVelocity | operator[] (int idx) const
double | redshift () const
| Returns this speed as a redshift measure.
std::string | SI_unit () const override
std::string | to_string (int decimals=3) const override
| Returns a string representation of this speed in km/s with the specified decimal places shown.
Coordinate | travel (const Interval &time) const
| Returns the distance travelled at this speed under the specified time interval.
Coordinate | travel (double seconds) const
| Returns the distance travelled at this speed under the specified time interval.
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 ScalarVelocity | from_redshift (double z)
| Instantiates a new speed instance from a given redshift value.
static const ScalarVelocity & | stationary ()
| Returns a reference to a statically defined zero speed of a stationary object.
static const ScalarVelocity & | undefined ()
| Returns a reference to a static instance of an undefined / invalid scalar velocity.

## 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 velocity (if signed) or speed (if unsigned).

Since
  1.6

See also
  Velocity

## Constructor & Destructor Documentation

## ScalarVelocity()

supernovas::ScalarVelocity::ScalarVelocity | ( | double | m_per_s | ) |

explicit

Instantiates a (signed) scalar velocity (speed) with the specified S.I.

value in m/s.

Parameters

  m_per_s | [m/s] the speed

Since
  1.6

See also
  from_redshift()

References supernovas::Scalar::Scalar(), supernovas::Validating::_valid, supernovas::Constant::c, supernovas::Validating::is_valid(), and m_per_s().

## Member Function Documentation

## abs()

ScalarVelocity supernovas::ScalarVelocity::abs | ( |  | ) | const

Returns the magnitude of this speed, as a unsigned speed.

Returns the unsigned magnitude of this (possibly signed) speed.

Since
  1.6

Returns
  The absolute value of the (possibly signed) speed value represented by this instance.
  the absolute value of this (possibly signed) speed.

Since
  1.6

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

## au_per_day()

double supernovas::ScalarVelocity::au_per_day | ( |  | ) | const

Returns this speed in AU/day.

Returns
  [AU/day] the speed value.

Since
  1.6

See also
  m_per_s(), km_per_s(), beta(), Gamma(), redshift()

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

## beta()

double supernovas::ScalarVelocity::beta | ( |  | ) | const

Returns this speed (v) as β = v / c.

Returns
  β = v / c

Since
  1.6

See also
  m_per_s(), km_per_s(), au_per_day(), Gamma(), redshift()

References supernovas::Scalar::_value, and supernovas::Constant::c.

Referenced by Gamma(), operator+(), and operator-().

## equals() [1/2]

bool supernovas::ScalarVelocity::equals | ( | const ScalarVelocity & | speed,
|  | const ScalarVelocity & | tolerance ) const

Checks if this speed equals the specified other speed within the tolerance.

Parameters

  speed | the reference speed
  tolerance | (optional) tolerance for the comparison (default: 0.001 m/s).

Returns
  true if this speed equals the argument within the tolerance, or else false

Since
  1.6

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

References equals(), and m_per_s().

## equals() [2/2]

bool supernovas::ScalarVelocity::equals | ( | const ScalarVelocity & | speed,
|  | double | tolerance = Unit::mm / Unit::sec ) const

Checks if this speed equals the specified other speed within the tolerance.

Parameters

  speed | the reference speed
  tolerance | [m/s] (optional) tolerance for the comparison (default: 0.001 m/s).

Returns
  true if this speed equals the argument within the tolerance, or else false

Since
  1.6

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

References supernovas::Scalar::_value.

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

## from_redshift()

ScalarVelocity supernovas::ScalarVelocity::from_redshift | ( | double | z | ) |

static

Instantiates a new speed instance from a given redshift value.

Parameters

  z | the redshift value.

Returns
  a scalar velocity instance corresponding to the specified redshift value.

Since
  1.6

References supernovas::Validating::is_valid(), supernovas::Unit::km_per_s, and novas_z2v().

## Gamma()

double supernovas::ScalarVelocity::Gamma | ( |  | ) | const

Returns the relativistic boost parameter Γ for this speed (v) as Γ = &radic (1 - v2 / c2).

Returns
  the relativistic boost Γ = &radic (1 - v2 / c2)

Since
  1.6

See also
  m_per_s(), km_per_s(), au_per_day(), redshift()

References beta().

## in_direction()

Velocity supernovas::ScalarVelocity::in_direction | ( | const Vector & | direction | ) | const

Returns a 3-dimensional velocity vector corresponding to this speed along the specified direction.

Parameters

  direction | a vector specifying the direction. Its magnitude is irrelevant.

Returns
  a new velocity vector, in the specified direction and with the magnitude of this speed.

Since
  1.6

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

## km_per_s()

double supernovas::ScalarVelocity::km_per_s | ( |  | ) | const

Returns this speed in km/s.

Returns
  [km/s] the speed value.

Since
  1.6

See also
  m_per_s(), au_per_day(), beta(), Gamma(), redshift()

References supernovas::Scalar::_value.

Referenced by supernovas::GeodeticObserver::GeodeticObserver(), redshift(), and to_string().

## m_per_s()

double supernovas::ScalarVelocity::m_per_s | ( |  | ) | const

Returns this speed in m/s.

Returns
  [m/s] the speed value.

Since
  1.6

See also
  km_per_s(), au_per_day(), beta(), Gamma(), redshift()

References supernovas::Scalar::_value.

Referenced by ScalarVelocity(), equals(), supernovas::Apparent::from_cirs(), supernovas::Apparent::from_tod(), supernovas::CatalogEntry::radial_velocity(), supernovas::Horizontal::to_apparent(), and supernovas::CatalogEntry::v_lsr().

## operator!=()

bool supernovas::ScalarVelocity::operator!= | ( | const ScalarVelocity & | speed | ) | const

Checks if this speed differs from the specified other speed, by more than 1 mm/s.

Parameters

  speed | the reference speed

Returns
  true if this speed differs from the argument by more than 1 mm/s, or else false

Since
  1.6

See also
  operator==()

References equals().

## operator*()

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

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

Parameters

  time | the time interval

Returns
  the distance travelled

Since
  1.6

See also
  travel()

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

## operator+()

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

Returns the signed scalar sum of this speed and the specified other speed, using the relativistic formula for addition.

Parameters

  r | the speed on the right-hand side

Returns
  the relativistic sum of this speed and the argument.

Since
  1.6

See also
  operator-()

References beta(), supernovas::Constant::c, and supernovas::Validating::is_valid().

## operator-()

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

Returns the signed scalar difference of this speed and the specified other speed, using the relativistic formula for addition.

Parameters

  r | the speed on the right-hand side

Returns
  the relativistic difference of this speed and the argument.

Since
  1.6

See also
  operator+()

References beta(), supernovas::Constant::c, and supernovas::Validating::is_valid().

## operator==()

bool supernovas::ScalarVelocity::operator== | ( | const ScalarVelocity & | speed | ) | const

Checks if this speed equals the specified other speed within 1 mm/s.

Parameters

  speed | the reference speed

Returns
  true if this speed equals the argument within 1 mm/s, or else false

Since
  1.6

See also
  equals(), operator!=()

References equals().

## operator[]()

ScalarVelocity supernovas::ScalarVelocity::operator[] | ( | int | idx | ) | const

## redshift()

double supernovas::ScalarVelocity::redshift | ( |  | ) | const

Returns this speed as a redshift measure.

Returns
  the equivalent redshift measure z.

Since
  1.6

See also
  m_per_s(), km_per_s(), au_per_day(), Gamma()

References km_per_s(), and novas_v2z().

## SI_unit()

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

override virtual

Implements supernovas::Scalar.

## stationary()

const ScalarVelocity & supernovas::ScalarVelocity::stationary | ( |  | ) |

static

Returns a reference to a statically defined zero speed of a stationary object.

Returns
  a reference to a static instance of zero speed.

Since
  1.6

## to_string()

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

override virtual

Returns a string representation of this speed in km/s with the specified decimal places shown.

Parameters

  decimals | (optional) the number of decimal places to print (default: 3)

Returns
  a new string containing a representation of this speed.

Since
  1.6

Reimplemented from supernovas::Scalar.

References km_per_s().

Referenced by supernovas::CatalogEntry::to_string(), and supernovas::Velocity::to_string().

## travel() [1/2]

Coordinate supernovas::ScalarVelocity::travel | ( | const Interval & | time | ) | const

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

Parameters

  time | the time interval

Returns
  the distance travelled

Since
  1.6

See also
  operator*(), Velocity::travel()

References supernovas::Interval::seconds(), and travel().

## travel() [2/2]

Coordinate supernovas::ScalarVelocity::travel | ( | double | seconds | ) | const

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

Parameters

  seconds | [s] the time interval

Returns
  the distance travelled

Since
  1.6

See also
  operator*(), Velocity::travel()

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

Referenced by supernovas::Interval::operator*(), operator*(), and travel().

## undefined()

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

static

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

Returns
  a reference to a standard undefined scalar velocity instance.

Since
  1.6

Referenced by supernovas::Track< CoordType >::radial_velocity_at().