![]() |
SuperNOVAS C++ API v1.6
High-precision C/C++ astrometry library
|
A generic 3D spatial vector, expressed in arbitrary units. More...
#include <supernovas.h>
Public Member Functions | |
| 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. | |
| virtual std::string | to_string (int decimals=3) const |
| Returns a string representation of this vector. | |
| 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(). | |
Protected Member Functions | |
| 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 | |
| double | _component [3] |
| [arb.u] Array containing the x, y, z components. | |
| Protected Attributes inherited from supernovas::Validating | |
| bool | _valid = false |
| the state variable. | |
|
protected |
Instantiates an undefined vector.
References _component.
Referenced by supernovas::Position::Position(), supernovas::Position::Position(), supernovas::Position::Position(), supernovas::Velocity::Velocity(), supernovas::Velocity::Velocity(), dot(), equals(), operator*(), projection_on(), scaled(), and unit_vector().
|
explicitprotected |
Instantiates a vector from its cartesian components.
References _component, supernovas::Validating::_valid, abs(), x(), y(), and z().
|
inlinevirtual |
| const double * supernovas::Vector::_array | ( | ) | const |
Returns the underlying double[3] C array that stores the components of this vector internally.
Such an array may be used with the SuperNOVAS C functions.
References _component.
Referenced by supernovas::GeodeticObserver::GeodeticObserver(), supernovas::SolarSystemObserver::SolarSystemObserver(), supernovas::AstrometricPosition::as_equatorial(), supernovas::Site::enu_to_itrs(), supernovas::Site::enu_to_itrs(), supernovas::ScalarVelocity::in_direction(), supernovas::Site::itrs_to_enu(), and supernovas::Site::itrs_to_enu().
| double supernovas::Vector::abs | ( | ) | const |
Returns the absolute value (length / magnitude) of this vector.
References _component, and novas_vlen().
Referenced by Vector(), supernovas::Velocity::Velocity(), supernovas::Position::distance(), supernovas::ScalarVelocity::in_direction(), supernovas::Position::operator==(), projection_on(), supernovas::Velocity::speed(), and unit_vector().
| double supernovas::Vector::dot | ( | const Vector & | v | ) | const |
Returns the dot product of this vector and the specified other vector.
| v | the other vector |
References Vector(), and _component.
Referenced by projection_on().
|
protected |
Checks if this vector is the same as another vector, within the specified precision.
| v | the reference vector |
| precision | precision for the equality test |
References Vector(), and _component.
Referenced by supernovas::Position::equals(), and supernovas::Velocity::equals().
| bool supernovas::Vector::is_zero | ( | ) | const |
Checks if this verctor is a null vector, that is all of its components are zero.
References _component.
Referenced by supernovas::GeocentricObserver::to_string(), supernovas::GeodeticObserver::to_string(), and supernovas::SolarSystemObserver::to_string().
| Vector supernovas::Vector::operator* | ( | double | r | ) | const |
Scales a vector by a factor, for example to cast it to/from a physical unit.
| r | scaling factor on the right-hand side |
References Vector(), supernovas::Validating::is_valid(), and scaled().
| double supernovas::Vector::operator[] | ( | int | idx | ) | const |
Returns the component at the specified index.
| idx | [0:2] The 0-based coordinate index. |
References _component.
| Angle supernovas::Vector::phi | ( | ) | const |
Returns the azumithal angle of this vector.
References _component, and supernovas::Validating::is_valid().
| double supernovas::Vector::projection_on | ( | const Vector & | v | ) | const |
| Vector supernovas::Vector::scaled | ( | double | factor | ) | const |
Returns a rescaled version of this vector, for example to cast it to/from a physical unit.
| factor | scaling factor, such as a cast to/from a physical unit |
References Vector(), _component, and supernovas::Validating::is_valid().
Referenced by supernovas::GeodeticObserver::GeodeticObserver(), supernovas::SolarSystemObserver::SolarSystemObserver(), operator*(), and unit_vector().
| Angle supernovas::Vector::theta | ( | ) | const |
Returns the polar angleof this vector, that is the angle from the z axis.
References _component, and supernovas::Validating::is_valid().
|
virtual |
Returns a string representation of this vector.
| decimals | (optional) the numberof decimal places to print for the components (default: 3). |
Reimplemented in supernovas::AstrometricPosition, supernovas::Position, and supernovas::Velocity.
References _component.
| Vector supernovas::Vector::unit_vector | ( | ) | const |
Returns a unit vector in the direction of this vector.
References Vector(), abs(), supernovas::Validating::is_valid(), and scaled().
| double supernovas::Vector::x | ( | ) | const |
Returns the x component of this vector.
References _component.
Referenced by Vector(), supernovas::Position::operator+(), supernovas::Velocity::operator+(), supernovas::Position::operator-(), supernovas::Velocity::operator-(), supernovas::Position::to_string(), supernovas::Velocity::to_string(), and supernovas::Velocity::travel().
| double supernovas::Vector::y | ( | ) | const |
Returns the y component of this vector.
References _component.
Referenced by Vector(), supernovas::Position::operator+(), supernovas::Velocity::operator+(), supernovas::Position::operator-(), supernovas::Velocity::operator-(), supernovas::Position::to_string(), supernovas::Velocity::to_string(), and supernovas::Velocity::travel().
| double supernovas::Vector::z | ( | ) | const |
Returns the z component of this vector.
References _component.
Referenced by Vector(), supernovas::Position::operator+(), supernovas::Velocity::operator+(), supernovas::Position::operator-(), supernovas::Velocity::operator-(), supernovas::Position::to_string(), supernovas::Velocity::to_string(), and supernovas::Velocity::travel().
|
protected |
[arb.u] Array containing the x, y, z components.
Referenced by Vector(), Vector(), _array(), abs(), dot(), equals(), supernovas::Position::inv(), supernovas::Velocity::inv(), is_zero(), supernovas::Position::operator/(), operator[](), phi(), scaled(), theta(), supernovas::Position::to_spherical(), to_string(), x(), y(), and z().