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

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

`#include <supernovas.h>`

Inheritance diagram for supernovas::Position:

## Public Member Functions

| Position (const double pos[3], double unit=Unit::m)
| Instantiates a new 3D cartesian position vector from its components in S.I.
| Position (double x_m, double y_m, double z_m)
| Instantiates a new 3D cartesian position vector from its components in S.I.
Coordinate | distance () const
| Returns the distance to the location indicated by this position (that is the absolute value of this position vector).
bool | equals (const Position &p, double precision) const
| Checks if this position is the same as another, within the specified precision.
Position | inv () const
| Returns a position vector with the same magnitude as this, but in the opposite direction.
bool | operator!= (const Position &p) const
| Checks if this position differs from the specified other position by more than the 12th significant figure, or 1mm (whichever is larger).
Position | operator+ (const Position &r) const
| Returns the sum of this position and another (relative) position.
Position | operator- (const Position &r) const
| Returns the difference of this position and another position.
Velocity | operator/ (const Interval &dt) const
| Returns the velocity vector that is equal to this position vector travelled under the specified time interval.
bool | operator== (const Position &p) const
| Checks if this position is the same as the specified other position to 12 significant figures, or 1mm (whichever is larger).
AstrometricPosition | to_astrometric (const Frame &frame, enum novas_reference_system system=NOVAS_TOD) const
| Returns this equatorial position vector as an astrometric position, referenced to the specified time and Solar-system barycentric observer location.
Spherical | to_spherical () const
| Converts this position vector to Spherical coordinates.
virtual std::string | to_string (int decimals=3) const override
| Returns a string represetation of this position vector, optionally setting the number of decimal places to show for each component.
Coordinate | x () const
| Returns the x component of this position vector.
Coordinate | y () const
| Returns the y component of this position vector.
Coordinate | z () const
| Returns the z component of this position 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 Position & | origin ()
| Returns a reference to the statically define position at the origin (that is a null posiution vector).
static const Position & | undefined ()
| Returns a reference to a statically defined standard invalid position vector.

## Protected Member Functions

| Position ()
| Instantiates an undefined position vector.
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;

## Additional Inherited Members

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 position vector in space.

Since
  1.6

See also
  AstrometricPosition, Interferometric, Geometric, Velocity

## Constructor & Destructor Documentation

## Position() [1/3]

supernovas::Position::Position | ( |  | ) |

inline protected

Instantiates an undefined position vector.

References supernovas::Vector::Vector().

Referenced by supernovas::AstrometricPosition::AstrometricPosition(), equals(), inv(), operator!=(), operator+(), operator-(), operator==(), origin(), supernovas::AstrometricPosition::reference(), supernovas::AstrometricPosition::referenced_to(), and undefined().

## Position() [2/3]

supernovas::Position::Position | ( | double | x_m,
|  | double | y_m,
|  | double | z_m )

explicit

Instantiates a new 3D cartesian position vector from its components in S.I.

units.

Parameters

  x_m | [m] x component
  y_m | [m] y component
  z_m | [m] z component

Since
  1.6

References supernovas::Vector::Vector(), and supernovas::Validating::_valid.

## Position() [3/3]

supernovas::Position::Position | ( | const double | pos[3],
|  | double | unit = Unit::m )

explicit

Instantiates a new 3D cartesian position vector from its components in S.I.

units.

Parameters

  pos | position 3-vector expressed in some physical unit
  unit | the physical unit, in which the components are given, such as Unit::m or Unit::au.

Since
  1.6

References supernovas::Vector::Vector().

## Member Function Documentation

## distance()

Coordinate supernovas::Position::distance | ( |  | ) | const

Returns the distance to the location indicated by this position (that is the absolute value of this position vector).

Since
  1.6

Returns
  the distance to the indicated position.

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

Referenced by supernovas::AstrometricPosition::obs_time(), and supernovas::AstrometricPosition::to_interferometric().

## equals()

bool supernovas::Position::equals | ( | const Position & | p,
|  | double | precision ) const

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

Parameters

  p | the reference position
  precision | the precision for testing equality.

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

Since
  1.6

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

References Position(), and supernovas::Vector::equals().

Referenced by supernovas::Site::equals(), and operator==().

## inv()

Position supernovas::Position::inv | ( |  | ) | const

Returns a position vector with the same magnitude as this, but in the opposite direction.

Since
  1.6

Returns
  the spatial inverse position vector of this one.

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

## operator!=()

bool supernovas::Position::operator!= | ( | const Position & | p | ) | const

Checks if this position differs from the specified other position by more than the 12th significant figure, or 1mm (whichever is larger).

Parameters

  p | the reference position

Returns
  true if this position equals the argument to 12 significant figures or 1 mm, or else false.

Since
  1.6

See also
  equals(), operator==()

References Position().

## operator+()

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

Returns the sum of this position and another (relative) position.

Parameters

  r | the other position on the right-hand side

Returns
  a new position vector with the sum of this position and the argument.

Since
  1.6

See also
  operator-()

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

## operator-()

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

Returns the difference of this position and another position.

Parameters

  r | the other position on the right-hand side

Returns
  a new position vector with the difference of this position and the argument.

Since
  1.6

See also
  operator+()

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

## operator/()

Velocity supernovas::Position::operator/ | ( | const Interval & | dt | ) | const

Returns the velocity vector that is equal to this position vector travelled under the specified time interval.

Parameters

  dt | the time interval on the right-hand-side of '/'.

Returns
  velocity v = x / dt, where x is this position vector.

Since
  1.6

See also
  Position::operator/()

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

## operator==()

bool supernovas::Position::operator== | ( | const Position & | p | ) | const

Checks if this position is the same as the specified other position to 12 significant figures, or 1mm (whichever is larger).

Parameters

  p | the reference position

Returns
  true if this position equals the argument to 12 significant figures or 1 mm, or else false.

Since
  1.6

See also
  equals(), operator!=()

References Position(), supernovas::Vector::abs(), equals(), and supernovas::Unit::mm.

## origin()

const Position & supernovas::Position::origin | ( |  | ) |

static

Returns a reference to the statically define position at the origin (that is a null posiution vector).

Returns
  a reference to a static null position vector.

Since
  1.6

References Position().

Referenced by supernovas::AstrometricPosition::referenced_to_ssb().

## to_astrometric()

AstrometricPosition supernovas::Position::to_astrometric | ( | const Frame & | frame,
|  | enum novas_reference_system | system = NOVAS_TOD ) const

Returns this equatorial position vector as an astrometric position, referenced to the specified time and Solar-system barycentric observer location.

IMPORTANT! Use this method only if you are 100% certain that the position represented by this instance is an equatorial rectangular position vector in the specified observing frame.

Parameters

  frame | Observing frame (observer location and time of observation)
  system | (optional) Equatorial coordinate reference system type used for the position and observer location (default: TOD).

Returns
  the astrometric position for this observed equatorial position vector, referenced to the time when light was emitted, and the observer location w.r.t. the Solar-system barycenter (SSB).

Since
  1.6

References supernovas::Validating::is_valid().

## to_spherical()

Spherical supernovas::Position::to_spherical | ( |  | ) | const

Converts this position vector to Spherical coordinates.

Returns
  a new instance of spherical coordinates corresponding to this position.

Since
  1.6

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

## to_string()

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

override virtual

Returns a string represetation of this position vector, optionally setting the number of decimal places to show for each component.

Parameters

  decimals | (optional) decimal places to print for the components (default: 3).

Returns
  a string representation of this position vector.

Since
  1.6

Reimplemented from supernovas::Vector.

Reimplemented in supernovas::AstrometricPosition.

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

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

## undefined()

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

static

Returns a reference to a statically defined standard invalid position vector.

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

Returns
  a reference to the static standard invalid vector.

Since
  1.6

References Position().

Referenced by supernovas::Apparent::astrometric_position(), supernovas::GeodeticObserver::gcrs_position_at(), supernovas::Observer::gcrs_position_at(), supernovas::Frame::observer_ssb_position(), and supernovas::Orbital::position().

## x()

Coordinate supernovas::Position::x | ( |  | ) | const

Returns the x component of this position vector.

Returns
  the x component

Since
  1.6

See also
  y(), z()

References supernovas::Vector::_component.

## y()

Coordinate supernovas::Position::y | ( |  | ) | const

Returns the y component of this position vector.

Returns
  the y component

Since
  1.6

See also
  x(), z()

References supernovas::Vector::_component.

## z()

Coordinate supernovas::Position::z | ( |  | ) | const

Returns the z component of this position vector.

Returns
  the z component

Since
  1.6

See also
  x(), y()

References supernovas::Vector::_component.