Loading...
Searching...
No Matches
supernovas::Velocity Class Reference
Geometric positions and velocities

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.
ScalarVelocity | x () const
| Returns the x component of this velocity vector.
ScalarVelocity | y () const
| Returns the y component of this velocity vector.
ScalarVelocity | z () const
| Returns the z component of this velocity vector.
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.
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 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.

Since
  1.6

See also
  ScalarVelocity, 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

Since
  1.6

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

  vel | The xyz 3-vector defining the components
  unit | (optional) the physical unit (e.g. Unit::kms, or Unit::AU_per_day) in which the components were specified (default: Unit:m / Unit::s = 1.0).

Since
  1.6

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

  v | the reference velocity
  precision | the precision for testing equality (default: 1 mm/s).

Returns
  true if this velocity equals the argument within the specified precision, or else false.

Since
  1.6

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.

Since
  1.6

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

  v | the reference velocity

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

Since
  1.6

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

  t | time interval

Returns
  the change in position of an object travelling at this velocity in the specified time interval.

Since
  1.6

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

  r | the other velocity on the right-hand side.

Returns
  the sum of this velocity and the argument.

Since
  1.6

See also
  operator-()

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

## 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

  r | the other velocity on the right-hand side.

Returns
  the sum of this velocity and the argument.

Since
  1.6

See also
  operator+()

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

  v | the reference velocity

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

Since
  1.6

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.

Since
  1.6

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.

Since
  1.6

## to_string()

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

override virtual

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.

Since
  1.6

Reimplemented from supernovas::Vector.

References supernovas::Vector::_component, and supernovas::ScalarVelocity::to_string().

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

  t | time interval

Returns
  the change in position of an object travelling at this velocity in the specified time interval.

Since
  1.6

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.

Since
  1.6

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

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

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

Since
  1.6

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

## x()

ScalarVelocity supernovas::Velocity::x | ( |  | ) | const

Returns the x component of this velocity vector.

Returns
  the x component

Since
  1.6

See also
  y(), z()

References supernovas::Vector::_component.

## y()

ScalarVelocity supernovas::Velocity::y | ( |  | ) | const

Returns the y component of this velocity vector.

Returns
  the y component

Since
  1.6

See also
  x(), z()

References supernovas::Vector::_component.

## z()

ScalarVelocity supernovas::Velocity::z | ( |  | ) | const

Returns the z component of this velocity vector.

Returns
  the z component

Since
  1.6

See also
  x(), y()

References supernovas::Vector::_component.