CppEphem
|
The CEAngle class defines an angle. It can be constructed either from: double: representing degrees or radians string: representing HH:MM:SS or DD:MM:SS
Methods are also provided to allow the user to retrieve the angle in whatever format they prefer
Public Member Functions | |
CEAngle () | |
Default constructor. More... | |
CEAngle (const CEAngle &other) | |
Construct from another CEAngle object. More... | |
CEAngle (const double &angle) | |
Construct from an angle in radians. More... | |
double | Deg (void) const |
Return angle in degrees as a double. More... | |
std::string | DmsStr (const char &delim=':') const |
Return string representing the angle in DD:MM:SS. More... | |
std::vector< double > | DmsVect (void) const |
Return vector of doubles representing the {degrees, arcmin, arcsec, arcsec-fraction}. More... | |
std::string | HmsStr (const char &delim=':') const |
Return string representing the angle in HH:MM:SS. More... | |
std::vector< double > | HmsVect (void) const |
Return vector of doubles representing the {hours, min, sec, sec-fraction}. More... | |
operator double () | |
Return a double object representing the angle in radians. More... | |
operator double () const | |
Return a double object representing the angle in radians. More... | |
CEAngle & | operator= (const CEAngle &other) |
Copy assignment operator. More... | |
CEAngle & | operator= (const double &other) |
Copy assignment operator from a double. More... | |
double | Rad (void) const |
Return angle in radians as a double. More... | |
void | SetAngle (const char *angle_str, const CEAngleType &angle_type, const char &delim=0) |
Set the angle from a string representing either HMS or DMS angles. More... | |
void | SetAngle (const double &angle, const CEAngleType &angle_type=CEAngleType::RADIANS) |
Set the angle from a double. More... | |
void | SetAngle (const std::vector< double > &angle_vec, const CEAngleType &angle_type) |
Set the angle from a vector of doubles representing HMS or DMS format. More... | |
virtual | ~CEAngle () |
Destructor. More... | |
Static Public Member Functions | |
static CEAngle | Deg (const double &angle) |
Return angle (radians) constructed from a degree angle. More... | |
static CEAngle | Dms (const char *angle_str, const char &delim=0) |
Return double constructed from a string representing degrees, minutes, seconds. More... | |
static CEAngle | Dms (const std::vector< double > &angle_vec) |
Return angle constructed from a string representing degrees, minutes, seconds. More... | |
static CEAngle | Hms (const char *angle_str, const char &delim=0) |
Return angle constructed from a string representing hours, minutes, seconds. More... | |
static CEAngle | Hms (const std::vector< double > &angle_vec) |
Return angle constructed from a string representing hours, minutes, seconds. More... | |
static CEAngle | Rad (const double &angle) |
Return angle constructed from a radians angle. More... | |
Private Member Functions | |
void | copy_members (const CEAngle &other) |
Copy data members from another CEAngle object. More... | |
void | free_members (void) |
Free allocated data members. More... | |
void | init_members (void) |
Initialize data members. More... | |
void | SetAngle_DmsVect (const std::vector< double > &angle) |
Set the angle from a vector of doubles of the form {degrees, arcmin, arcsec}. More... | |
void | SetAngle_HmsVect (const std::vector< double > &angle) |
Set the angle from a vector of doubles representing {hours, minutes, seconds}. More... | |
Private Attributes | |
double | angle_ |
Angle stored in radians. More... | |
#include <CEAngle.h>
CEAngle::CEAngle | ( | ) |
Default constructor.
Definition at line 38 of file CEAngle.cpp.
CEAngle::CEAngle | ( | const double & | angle | ) |
Construct from an angle in radians.
[in] | angle | Angle in radians |
The provided angle
is assumed to be in units of radians
Definition at line 51 of file CEAngle.cpp.
|
explicit |
Construct from another CEAngle object.
[in] | other | CEAngle to copy data members from |
Definition at line 63 of file CEAngle.cpp.
|
virtual |
Destructor.
Definition at line 73 of file CEAngle.cpp.
|
private |
Copy data members from another CEAngle object.
[in] | other | CEAngle object to copy from |
Definition at line 593 of file CEAngle.cpp.
|
static |
Return angle (radians) constructed from a degree angle.
[in] | angle | Angle in degrees |
Definition at line 317 of file CEAngle.cpp.
double CEAngle::Deg | ( | void | ) | const |
Return angle in degrees as a double.
Definition at line 328 of file CEAngle.cpp.
|
static |
Return double constructed from a string representing degrees, minutes, seconds.
[in] | angle_str | Angle representing degrees, arcmins, arcsecs |
[in] | delim | Delimiter, by default all methods will be tested |
The following values for delim
are special cases:
Definition at line 234 of file CEAngle.cpp.
|
static |
Return angle constructed from a string representing degrees, minutes, seconds.
[in] | angle_vec | Angle representing degrees, minutes, seconds |
The input angle
is represented in the following manner [0] = degrees [1] = minutes [2] = seconds [3] = (optional) seconds fraction The index [3] is optional if index [2] contains the whole seconds portion
Definition at line 256 of file CEAngle.cpp.
std::string CEAngle::DmsStr | ( | const char & | delim = ':' | ) | const |
Return string representing the angle in DD:MM:SS.
[in] | delim | Delimiter to use in output string |
Definition at line 270 of file CEAngle.cpp.
std::vector< double > CEAngle::DmsVect | ( | void | ) | const |
Return vector of doubles representing the {degrees, arcmin, arcsec, arcsec-fraction}.
The returned vector has the following elements [0] = degrees [1] = arcminutes [2] = arcseconds [3] = arcseconds fraction
Definition at line 291 of file CEAngle.cpp.
|
private |
Free allocated data members.
Definition at line 581 of file CEAngle.cpp.
|
static |
Return angle constructed from a string representing hours, minutes, seconds.
[in] | angle_str | Angle representing hours, minutes, seconds |
[in] | delim | Delimiter, by default all methods will be tested |
The following values for delim
are special cases:
Definition at line 142 of file CEAngle.cpp.
|
static |
Return angle constructed from a string representing hours, minutes, seconds.
[in] | angle_vec | Angle representing hours, minutes, seconds |
The input angle
is represented in the following manner [0] = hours [1] = minutes [2] = seconds [3] = (optional) seconds fraction The index [3] is optional if index [2] contains the whole seconds portion
Definition at line 164 of file CEAngle.cpp.
std::string CEAngle::HmsStr | ( | const char & | delim = ':' | ) | const |
Return string representing the angle in HH:MM:SS.
[in] | delim | Delimiter to use in output string |
Definition at line 178 of file CEAngle.cpp.
std::vector< double > CEAngle::HmsVect | ( | void | ) | const |
Return vector of doubles representing the {hours, min, sec, sec-fraction}.
The returned vector has the following elements [0] = hours [1] = minutes [2] = seconds [3] = seconds fraction
Definition at line 199 of file CEAngle.cpp.
|
private |
Initialize data members.
Definition at line 602 of file CEAngle.cpp.
CEAngle::operator double | ( | ) |
Return a double object representing the angle in radians.
Definition at line 114 of file CEAngle.cpp.
CEAngle::operator double | ( | ) | const |
Return a double object representing the angle in radians.
Definition at line 123 of file CEAngle.cpp.
Copy assignment operator.
[in] | other | CEAngle object to copy objects from |
other
Definition at line 85 of file CEAngle.cpp.
CEAngle & CEAngle::operator= | ( | const double & | other | ) |
Copy assignment operator from a double.
[in] | other | double angle (radians) |
other
Definition at line 102 of file CEAngle.cpp.
|
static |
Return angle constructed from a radians angle.
[in] | angle | Angle in radians |
Definition at line 340 of file CEAngle.cpp.
double CEAngle::Rad | ( | void | ) | const |
Return angle in radians as a double.
Definition at line 351 of file CEAngle.cpp.
void CEAngle::SetAngle | ( | const char * | angle_str, |
const CEAngleType & | angle_type, | ||
const char & | delim = 0 |
||
) |
Set the angle from a string representing either HMS or DMS angles.
[in] | angle | Angle represented by a HMS or DMS string |
[in] | angle_type | CEAngleType (only HMS or DMS are accepted) |
[in] | delim | Delimiter used to separate different components in angle |
An exception is thrown if angle_type
is neither HMS or DMS
Definition at line 400 of file CEAngle.cpp.
void CEAngle::SetAngle | ( | const double & | angle, |
const CEAngleType & | angle_type = CEAngleType::RADIANS |
||
) |
Set the angle from a double.
[in] | angle | Angle value |
[in] | angle_type | CEAngleType (only DEGREES or RADIANS are accepted) |
CEException::invalid_value | angle_type is neither DEGREES nor RADIANS |
This method calls the SOFA function iauAnp to ensure the angle is in the range [0, 2pi).
Definition at line 369 of file CEAngle.cpp.
void CEAngle::SetAngle | ( | const std::vector< double > & | angle_vec, |
const CEAngleType & | angle_type | ||
) |
Set the angle from a vector of doubles representing HMS or DMS format.
[in] | angle_vec | Angle as a vector of doubles |
[in] | angle_type | Angle type of angle_vec |
An exception is thrown if angle_type
is neither HMS or DMS
Definition at line 466 of file CEAngle.cpp.
|
private |
Set the angle from a vector of doubles of the form {degrees, arcmin, arcsec}.
[in] | angle | Angle as a vector of doubles |
The angle
parameter should contain degrees and arcmins as whole numbers, as they will be be cast to integers. The arcsecs parameter is assumed to be at index [2], or split across index [2] and [3] if "angle.size() == 4". This allows dividing the seconds across two indices.
Definition at line 541 of file CEAngle.cpp.
|
private |
Set the angle from a vector of doubles representing {hours, minutes, seconds}.
[in] | angle | Angle as a vector of doubles |
The angle
parameter should contain hours and minutes as whole numbers, as they will be be cast to integers. The seconds parameter is assumed to be at index [2], or split across index [2] and [3] if "angle.size() == 4". This allows dividing the seconds across two indices.
Definition at line 496 of file CEAngle.cpp.
|
mutableprivate |