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

Spherical coordinates (longitude, latitude), representing a direction on sky. More...

#include <supernovas.h>

Inheritance diagram for supernovas::Spherical:

Public Member Functions

 Spherical (const Angle &longitude, const Angle &latitude)
 Instantiates new spherical coordinates with the specified components.
 Spherical (const std::string &longitude, const std::string &latitude)
 Instantiates spherical coordinates with the specified string representations of the longitude and latitude coordinates, optionally specifying a system and a distance if needed.
 Spherical (double longitude_rad, double latitude_rad)
 Instantiates new spherical coordinates with the specified components.
virtual ~Spherical ()
const Anglelatitude () const
 Returns the latitude coordinate as an angle.
const Anglelongitude () const
 Returns the longitude coordinate as an angle.
virtual std::string to_string (enum novas_separator_type separator=NOVAS_SEP_UNITS_AND_SPACES, int decimals=3) const
 Returns a string representation of these spherical coordinates in DMS format, optionally specifying the type of separator to use and the precision to print.
Position xyz (const Coordinate &distance) const
 Returns the cartesian position vector corresponding to these spherical coordinates.
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

 Spherical ()
 Instantiates invalid spherical coordinates.
Angle distance_to (const Spherical &other) const
 Returns the angular distance of these spherical coordiantes to/from the specified other spherical coordinates.
bool equals (const Spherical &other, double precision) const
Protected Member Functions inherited from supernovas::Validating
 Validating ()
 dummy constructor;

Additional Inherited Members

Protected Attributes inherited from supernovas::Validating
bool _valid = false
 the state variable.

Detailed Description

Spherical coordinates (longitude, latitude), representing a direction on sky.

See also
Position, Equatorial, Ecliptic, Galactic, Horizontal

Constructor & Destructor Documentation

◆ Spherical() [1/4]

◆ ~Spherical()

virtual supernovas::Spherical::~Spherical ( )
inlinevirtual

◆ Spherical() [2/4]

supernovas::Spherical::Spherical ( double longitude_rad,
double latitude_rad )

Instantiates new spherical coordinates with the specified components.

Parameters
longitude_rad[rad] longitude coordinate
latitude_rad[rad] latitude coordinate

References supernovas::Validating::_valid, and supernovas::Constant::half_pi.

◆ Spherical() [3/4]

supernovas::Spherical::Spherical ( const Angle & longitude,
const Angle & latitude )

Instantiates new spherical coordinates with the specified components.

Parameters
longitudelongitude coordinate
latitudelatitude coordinate

References Spherical(), latitude(), and longitude().

◆ Spherical() [4/4]

supernovas::Spherical::Spherical ( const std::string & lon,
const std::string & lat )

Instantiates spherical coordinates with the specified string representations of the longitude and latitude coordinates, optionally specifying a system and a distance if needed.

After instantiation, you should check that the resulting coordinates are valid, e.g. as:

Spherical coords = Spherical(..., ...);
if(!coords.is_valid()) {
// oops, looks like the angles could not be parsed...
return;
}
Spherical()
Instantiates invalid spherical coordinates.
Definition supernovas.h:805
bool is_valid() const
Returns the previously set 'valid' stae of the implementing instance.
Definition supernovas.h:247
Parameters
lonstring representation of the longitude coordinate in DMS or a decimnal degrees.
latstring representation of the declination coordinate as DMS or decimal degrees.
See also
novas_str_degrees() for details on string representation that can be parsed.
novas_parse_degrees() for more managed parsing from strings.

References Spherical().

Member Function Documentation

◆ distance_to()

Angle supernovas::Spherical::distance_to ( const Spherical & other) const
protected

Returns the angular distance of these spherical coordiantes to/from the specified other spherical coordinates.

Parameters
otherthe reference spherical coordinates
Returns
the angular distance of these coordinates to/from the argument.

References Spherical(), supernovas::Angle::deg(), supernovas::Unit::deg, supernovas::Validating::is_valid(), and novas_sep().

Referenced by supernovas::Ecliptic::distance_to(), supernovas::Equatorial::distance_to(), supernovas::Galactic::distance_to(), supernovas::Horizontal::distance_to(), and equals().

◆ equals()

bool supernovas::Spherical::equals ( const Spherical & other,
double precision ) const
inlineprotected

◆ latitude()

◆ longitude()

◆ to_string()

std::string supernovas::Spherical::to_string ( enum novas_separator_type separator = NOVAS_SEP_UNITS_AND_SPACES,
int decimals = 3 ) const
virtual

Returns a string representation of these spherical coordinates in DMS format, optionally specifying the type of separator to use and the precision to print.

Parameters
separator(optional) the type of separators to use for the DMS representations of the components (default: units and spaces).
decimals(optional) the number of decimal places to print for the seconds (default: 3)
Returns
a new string with the human-readable representation of these spherical coordinates.

Reimplemented in supernovas::Ecliptic, supernovas::Equatorial, supernovas::Galactic, and supernovas::Horizontal.

References supernovas::Angle::to_string().

Referenced by supernovas::Ecliptic::to_string(), supernovas::Galactic::to_string(), and supernovas::Horizontal::to_string().

◆ xyz()

Position supernovas::Spherical::xyz ( const Coordinate & distance) const

Returns the cartesian position vector corresponding to these spherical coordinates.

Returns
the equivalent rectanguar position vector.
See also
Position::to_spherical()

References supernovas::Validating::is_valid(), and supernovas::Coordinate::m().