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

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

Detailed Description

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

See also
Position ,

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
See also
from_redshift()

References supernovas::Validating::_valid, supernovas::Constant::c, 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.

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

References 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.
See also
m_per_s(), km_per_s(), beta(), Gamma(), redshift()

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

◆ beta()

double supernovas::ScalarVelocity::beta ( ) const

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

Returns
β = v / c
See also
m_per_s(), km_per_s(), au_per_day(), Gamma(), redshift()

References 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
speedthe 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
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
speedthe 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
See also
operator==(), operator!=()

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
zthe redshift value.
Returns
a scalar velocity instance corresponding to the specified redshift value.

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

◆ 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)
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
directiona vector specifying the direction. Its magnitude is irrelevant.
Returns
a new velocity vector, in the specified direction and with the magnitude of this speed.

References supernovas::Vector::_array(), 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.
See also
m_per_s(), au_per_day(), beta(), Gamma(), redshift()

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

◆ m_per_s()

◆ 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
speedthe reference speed
Returns
true if this speed differs from the argument by more than 1 mm/s, or else false
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 of observation and astronomical timescalesthe time interval
Returns
the distance travelled
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
rthe speed on the right-hand side
Returns
the relativistic sum of this speed and the argument.
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
rthe speed on the right-hand side
Returns
the relativistic difference of this speed and the argument.
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
speedthe reference speed
Returns
true if this speed equals the argument within 1 mm/s, or else false
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.
See also
m_per_s(), km_per_s(), au_per_day(), Gamma()

References km_per_s(), and novas_v2z().

◆ 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.

◆ to_string()

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

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.

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 of observation and astronomical timescalesthe time interval
Returns
the distance travelled
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
See also
operator*(), Velocity::travel()

References 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.

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