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

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.
AstrometricPosition as_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.
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 is differs fro 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).
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.
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 Positionorigin ()
 Returns a reference to the statically define position at the origin (that is a null posiution vector).
static const Positionundefined ()
 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.

See also
Velocity, Geometric

Constructor & Destructor Documentation

◆ Position() [1/3]

◆ 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

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
posposition 3-vector expressed in some physical unit
unitthe physical unit, in which the components are given, such as Unit::m or Unit::au.

References supernovas::Vector::Vector().

Member Function Documentation

◆ as_astrometric()

AstrometricPosition supernovas::Position::as_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
Observing framesObserving 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).

References supernovas::Validating::is_valid().

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

Returns
the distance to the indicated position.

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

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

◆ 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
pthe reference position
precisionthe precision for testing equality.
Returns
true if this position equals the argument within the specified precision, or else false.
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.

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 is differs fro the specified other position by more than the 12th significant figure, or 1mm (whichever is larger).

Parameters
pthe reference position
Returns
true if this position equals the argument to 12 significant figures or 1mm, or else false.
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
rthe other position on the right-hand side
Returns
a new position vector with the sum of this position and the argument.
See also
operator-()

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

◆ operator-()

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

Returns the difference of this position and another position.

Parameters
rthe other position on the right-hand side
Returns
a new position vector with the difference of this position and the argument.
See also
operator+()

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

◆ 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
dtthe time interval on the right-hand-side of '/'.
Returns
velocity v = x / dt, where x is this position vector.
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
pthe reference position
Returns
true if this position equals the argument to 12 significant figures or 1mm, or else false.
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.

References Position().

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

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

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

◆ to_string()

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

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.

Reimplemented from supernovas::Vector.

Reimplemented in supernovas::AstrometricPosition.

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

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.

References Position().

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