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

Abstract base class for scalar quantities, expressed in standard S.I. More...

#include <supernovas.h>

+ Inheritance diagram for supernovas::Scalar:

Public Member Functions

virtual ~Scalar ()
 
bool equals (const Scalar &other, double precision) const
 Checks if this scalar quantity is the same as another, within the specified precision.
 
virtual std::string SI_unit () const =0
 
double SI_value () const
 The value of this scalar quantity in S.I.
 
virtual std::string to_string (int decimals=3) const
 Returns a human readable representation of this scalar quantity.
 
- 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().
 

Protected Member Functions

 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

double _value
 The value in S.I. units.
 
- Protected Attributes inherited from supernovas::Validating
bool _valid = false
 the state variable.
 

Detailed Description

Abstract base class for scalar quantities, expressed in standard S.I.

units.

Since
1.6
See also
Angle, TimeAngle, Interval, Coordinate, ScalarVelocity, Temperature, Pressure

Constructor & Destructor Documentation

◆ Scalar() [1/2]

supernovas::Scalar::Scalar ( )
inlineprotected

Instantiates a standard undefined (invalid) scalar quantity with NAN value.

References _value.

Referenced by supernovas::Angle::Angle(), supernovas::Coordinate::Coordinate(), supernovas::Interval::Interval(), supernovas::ScalarVelocity::ScalarVelocity(), and equals().

◆ Scalar() [2/2]

supernovas::Scalar::Scalar ( double SI_value)
protected

Instantiates a scalar quantity with an initializing value in standard S.I.

units.

Parameters
SI_valuethe initializing value in S.I. units.
Since
1.6

References supernovas::Validating::_valid, _value, and SI_value().

◆ ~Scalar()

virtual supernovas::Scalar::~Scalar ( )
inlinevirtual

Member Function Documentation

◆ equals()

bool supernovas::Scalar::equals ( const Scalar & other,
double precision ) const

Checks if this scalar quantity is the same as another, within the specified precision.

Two scalar quantities are equal only if they have the same S.I. units and the same S.I. values within the specified precision.

Parameters
otherAnother scalar quantity.
precisionPrecision for the comparison in the same S.I. units as this quantity.
Returns
true if the two scalars have the same S.I. units and values within the specified precision, otherwise false.
Since
1.6

References Scalar(), _value, and SI_unit().

◆ SI_unit()

virtual std::string supernovas::Scalar::SI_unit ( ) const
pure virtual

◆ SI_value()

double supernovas::Scalar::SI_value ( ) const

The value of this scalar quantity in S.I.

units. All concrete subclasses must implement this.

Returns
the value in the standard S.I. units.
Since
1.6

References _value.

Referenced by Scalar().

◆ to_string()

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

Returns a human readable representation of this scalar quantity.

Subclasses may override the default implementation to provide their own.

Parameters
decimals(optional) [0:16] Number of decimal places to print (default: 3).
Returns
a string representation of this scalar quantity.
Since
1.6

Reimplemented in supernovas::Angle, supernovas::Coordinate, supernovas::Interval, supernovas::Pressure, supernovas::ScalarVelocity, and supernovas::Temperature.

References _value, and SI_unit().

Member Data Documentation

◆ _value

double supernovas::Scalar::_value
protected

The value in S.I. units.

Referenced by Scalar(), Scalar(), supernovas::TimeAngle::TimeAngle(), supernovas::Coordinate::abs(), supernovas::ScalarVelocity::abs(), supernovas::Angle::arcmin(), supernovas::Angle::arcsec(), supernovas::Pressure::atm(), supernovas::Coordinate::au(), supernovas::ScalarVelocity::au_per_day(), supernovas::Pressure::bar(), supernovas::ScalarVelocity::beta(), supernovas::Temperature::celsius(), supernovas::Interval::days(), supernovas::Angle::deg(), supernovas::Angle::equals(), equals(), supernovas::ScalarVelocity::equals(), supernovas::Angle::fraction(), supernovas::Coordinate::Gpc(), supernovas::Interval::hours(), supernovas::TimeAngle::hours(), supernovas::Pressure::hPa(), supernovas::ScalarVelocity::in_direction(), supernovas::Interval::inv(), supernovas::Interval::julian_centuries(), supernovas::Interval::julian_years(), supernovas::Temperature::kelvin(), supernovas::Coordinate::km(), supernovas::ScalarVelocity::km_per_s(), supernovas::Pressure::kPa(), supernovas::Coordinate::kpc(), supernovas::Coordinate::lyr(), supernovas::Coordinate::m(), supernovas::ScalarVelocity::m_per_s(), supernovas::Angle::mas(), supernovas::Pressure::mbar(), supernovas::Interval::milliseconds(), supernovas::Interval::minutes(), supernovas::Coordinate::Mpc(), supernovas::TimeAngle::operator+(), supernovas::TimeAngle::operator-(), supernovas::Coordinate::operator/(), supernovas::Pressure::Pa(), supernovas::Coordinate::pc(), supernovas::Angle::rad(), supernovas::Interval::seconds(), SI_value(), supernovas::Coordinate::to_string(), supernovas::Interval::to_string(), supernovas::Pressure::to_string(), to_string(), supernovas::Pressure::torr(), supernovas::ScalarVelocity::travel(), supernovas::Angle::uas(), supernovas::Interval::weeks(), and supernovas::Interval::years().