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

A 3D physical velocity vector in space. More...

#include <supernovas.h>

Inheritance diagram for supernovas::Velocity:

Public Member Functions

 Velocity (const double vel[3], double unit=1.0)
 Instantiates a new velocity vector from its xyz components, specified in the given physical unit.
 Velocity (double x_ms, double y_ms, double z_ms)
 Instantiates a new velocity vector from its xyz components.
bool equals (const Velocity &v, double precision=Unit::mm/Unit::s) const
 Checks if this velocity is the same as another, within the specified precision.
Velocity inv () const
 Returns the velocity with the same magnitude as this, but moving in the opposite direction.
bool operator!= (const Velocity &v) const
 Checks if this velocity is the same as another, within 1 mm/s.
Position operator* (const Interval &t) const
 Returns the vector travelled in the given time interval at this velocity.
Velocity operator+ (const Velocity &r) const
 Returns the sum of this velocity and the specified other velocity.
Velocity operator- (const Velocity &r) const
 Returns the difference of this velocity and the specified other velocity.
bool operator== (const Velocity &v) const
 Checks if this velocity is the same as another, within 1 mm/s.
ScalarVelocity speed () const
 Returns the speed (absolute value) of this velocity vector.
std::string to_string (int decimals=3) const override
 Returns a string representation of this velocity with the requested decimal precision.
Position travel (const Interval &t) const
 Returns the vector travelled in the given time interval at this velocity.
Position travel (double seconds) const
 Returns the vector travelled in the given time interval at this velocity.
Public Member Functions inherited from supernovas::Vector
virtual ~Vector ()
const double * _array () const
 Returns the underlying double[3] C array that stores the components of this vector internally.
double abs () const
 Returns the absolute value (length / magnitude) of this vector.
double dot (const Vector &v) const
 Returns the dot product of this vector and the specified other vector.
bool is_zero () const
 Checks if this verctor is a null vector, that is all of its components are zero.
Vector operator* (double r) const
 Scales a vector by a factor, for example to cast it to/from a physical unit.
double operator[] (int idx) const
 Returns the component at the specified index.
Angle phi () const
 Returns the azumithal angle of this vector.
double projection_on (const Vector &v) const
 Returns the projection of this vector along the direction of another vector.
Vector scaled (double factor) const
 Returns a rescaled version of this vector, for example to cast it to/from a physical unit.
Angle theta () const
 Returns the polar angleof this vector, that is the angle from the z axis.
Vector unit_vector () const
 Returns a unit vector in the direction of this vector.
double x () const
 Returns the x component of this vector.
double y () const
 Returns the y component of this vector.
double z () const
 Returns the z component of this vector.
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 Velocity & stationary ()
 Returns a reference to the statically defined zero velocity of a stationary object.
static const Velocity & undefined ()
 Returns a reference to the statically defined standard invalid velocity.

Additional Inherited Members

Protected Member Functions inherited from supernovas::Vector
 Vector ()
 Instantiates an undefined vector.
 Vector (double x, double y, double z)
 Instantiates a vector from its cartesian components.
bool equals (const Vector &v, double precision) const
 Checks if this vector is the same as another vector, within the specified precision.
Protected Member Functions inherited from supernovas::Validating
 Validating ()
 dummy constructor;
Protected Attributes inherited from supernovas::Vector
double _component [3]
 [arb.u] Array containing the x, y, z components.
Protected Attributes inherited from supernovas::Validating
bool _valid = false
 the state variable.

Detailed Description

A 3D physical velocity vector in space.

See also
Velocity, Geometric

Constructor & Destructor Documentation

◆ Velocity() [1/2]

supernovas::Velocity::Velocity ( double x_ms,
double y_ms,
double z_ms )
explicit

Instantiates a new velocity vector from its xyz components.

Parameters
x_ms[m/s] x component
y_ms[m/s] y component
z_ms[m/s] z component

References supernovas::Vector::Vector(), supernovas::Validating::_valid, supernovas::Vector::abs(), and supernovas::Constant::c.

◆ Velocity() [2/2]

supernovas::Velocity::Velocity ( const double vel[3],
double unit = 1.0 )
explicit

Instantiates a new velocity vector from its xyz components, specified in the given physical unit.

Parameters
velThe xyz 3-vector defining the components
unit(optional) the physical unit (e.g. Unit::kms, or Unit::au / Unit::day) in which the components were specified (default: Unit:m / Unit::s = 1.0).

References supernovas::Vector::Vector().

Member Function Documentation

◆ equals()

bool supernovas::Velocity::equals ( const Velocity & v,
double precision = Unit::mm / Unit::s ) const

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

Parameters
vthe reference velocity
precisionthe precision for testing equality (default: 1 mm/s).
Returns
true if this velocity equals the argument within the specified precision, or else false.
See also
operator==(), operator!=()

References supernovas::Vector::equals().

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

◆ inv()

Velocity supernovas::Velocity::inv ( ) const

Returns the velocity with the same magnitude as this, but moving in the opposite direction.

Returns
the velocity in the opposite direction.

References supernovas::Vector::_component, and supernovas::Validating::is_valid().

◆ operator!=()

bool supernovas::Velocity::operator!= ( const Velocity & v) const

Checks if this velocity is the same as another, within 1 mm/s.

Parameters
vthe reference velocity
Returns
true if this velocity equals the argument within 1 mm/s, or else false.
See also
operator==()

References equals(), supernovas::Unit::mm, and supernovas::Unit::sec.

◆ operator*()

Position supernovas::Velocity::operator* ( const Interval & t) const

Returns the vector travelled in the given time interval at this velocity.

Parameters
ttime interval
Returns
the change in position of an object travelling at this velocity in the specified time interval.
See also
travel(), ScalarVelocity:travel()

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

◆ operator+()

Velocity supernovas::Velocity::operator+ ( const Velocity & r) const

Returns the sum of this velocity and the specified other velocity.

The sum is calculated using the relativistic formula.

Parameters
rthe other velocity on the right-hand side.
Returns
the sum of this velocity and the argument.
See also
operator-()

References supernovas::Validating::is_valid(), supernovas::Vector::x(), supernovas::Vector::y(), and supernovas::Vector::z().

◆ operator-()

Velocity supernovas::Velocity::operator- ( const Velocity & r) const

Returns the difference of this velocity and the specified other velocity.

The difference is calculated using the relativistic formula.

Parameters
rthe other velocity on the right-hand side.
Returns
the sum of this velocity and the argument.
See also
operator+()

References supernovas::Validating::is_valid(), supernovas::Vector::x(), supernovas::Vector::y(), and supernovas::Vector::z().

◆ operator==()

bool supernovas::Velocity::operator== ( const Velocity & v) const

Checks if this velocity is the same as another, within 1 mm/s.

Parameters
vthe reference velocity
Returns
true if this velocity equals the argument within 1 mm/s, or else false.
See also
equals(), operator!=()

References equals(), supernovas::Unit::mm, and supernovas::Unit::sec.

◆ speed()

ScalarVelocity supernovas::Velocity::speed ( ) const

Returns the speed (absolute value) of this velocity vector.

Returns
the speed (absolute value) of this velocity.

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

◆ stationary()

const Velocity & supernovas::Velocity::stationary ( )
static

Returns a reference to the statically defined zero velocity of a stationary object.

Returns
the static reference to a stationary object with zero velocity

◆ to_string()

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

Returns a string representation of this velocity with the requested decimal precision.

Parameters
decimals(optional) the number of decimnal places to print for the components
Returns
a new string with a representation of this velocity.

Reimplemented from supernovas::Vector.

References supernovas::ScalarVelocity::to_string(), supernovas::Vector::x(), supernovas::Vector::y(), and supernovas::Vector::z().

Referenced by supernovas::GeocentricObserver::to_string(), supernovas::GeodeticObserver::to_string(), supernovas::Geometric::to_string(), and supernovas::SolarSystemObserver::to_string().

◆ travel() [1/2]

Position supernovas::Velocity::travel ( const Interval & t) const

Returns the vector travelled in the given time interval at this velocity.

Parameters
ttime interval
Returns
the change in position of an object travelling at this velocity in the specified time interval.
See also
operator*(), ScalarVelocity:travel()

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

◆ travel() [2/2]

Position supernovas::Velocity::travel ( double seconds) const

Returns the vector travelled in the given time interval at this velocity.

Parameters
seconds[s] time interval
Returns
the change in position of an object travelling at this velocity in the specified time interval.
See also
operator*(), ScalarVelocity:travel()

References supernovas::Validating::is_valid(), supernovas::Vector::x(), supernovas::Vector::y(), and supernovas::Vector::z().

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

◆ undefined()

const Velocity & supernovas::Velocity::undefined ( )
static

Returns a reference to the statically defined standard invalid velocity.

This invalid velocity may be used inside any object that is invalid itself.

Returns
the static reference to a standard invalid velocity

Referenced by supernovas::Frame::observer_ssb_velocity(), and supernovas::Orbital::velocity().