TwiceAsNice
2019-02-18
|
An angle, stored as degrees, but expressible in many ways. More...
#include <DMS.h>
Public Member Functions | |
DMS (int d=0, int m=0, int s=0, int ms=0) | |
Default Constructor. More... | |
DMS (int d, int m, const double &s) | |
Constructor. More... | |
DMS (const double &x) | |
Construct an angle from a double value. More... | |
DMS (const Nice::Time &_t) | |
Ctor from a time value. More... | |
bool | isValid () const |
operator double () const | |
Cast operator DMSVar (empty). More... | |
bool | operator== (const DMS &d) const |
equal ?. More... | |
int | degree () const |
int | arcmin () const |
int | arcsec () const |
int | marcsec () const |
const double & | degrees () const |
int | hour () const |
int | minute () const |
int | second () const |
int | msecond () const |
double | hours () const |
void | setDeg (int d) |
Sets integer degrees portion of angle, leaving the arcminute and arcsecond values intact. More... | |
void | setArcMin (int m) |
Sets integer arcminutes portion of angle, leaving the degrees and arcsecond values intact. More... | |
void | setArcSec (int s) |
Sets integer arcseconds portion of angle, leaving the degrees and arcminute values intact. More... | |
void | setD (const double &x) |
Sets floating-point value of angle, in degrees. More... | |
void | setD (int d, int m, int s, int ms) |
Sets floating-point value of angle, in degrees. More... | |
void | setD (int d, int m, const double &s) |
Sets floating-point value of angle, in degrees. More... | |
void | setHour (int h) |
Sets integer hours portion of angle, leaving the minutes and seconds values intact. More... | |
void | setHMin (int m) |
Sets integer minutes portion of angle, leaving the hours and seconds values intact. More... | |
void | setHSec (int s) |
Sets integer seconds portion of angle, leaving the hours and minutes values intact. More... | |
void | setH (const double &x) |
Sets floating-point value of angle, in hours. More... | |
void | setH (int h, int m, int s, int ms) |
Sets floating-point value of angle, in hours. More... | |
void | setH (int h, int m, const double &s) |
Sets floating-point value of angle, in hours. More... | |
void | set (const DMS &d) |
Copy value of another DMS angle. More... | |
void | set (const double &d) |
Copy value of another DMS angle. More... | |
DMS | operator+ (DMS d) |
Addition operator. More... | |
DMS & | operator+= (const DMS &d) |
Addition operator. More... | |
DMS | operator- (DMS d) |
Subtraction operator. More... | |
DMS & | operator-= (const DMS &d) |
Subtraction operator. More... | |
void | sinCos (double &s, double &c) const |
Compute sine and cosine of the angle simultaneously. More... | |
double | sin () const |
Compute the Angle's m_sine. More... | |
double | cos () const |
Compute the Angle's m_cosine. More... | |
double | radians () const |
Express the angle in radians. More... | |
void | setRadians (const double &a) |
Set angle according to the argument, in radians. More... | |
double | reduce () const |
return the equivalent angle between 0 and 360 degrees, in units of degrees. More... | |
std::string | toDMSString (const bool forceSign=true) const |
std::string | toHMSString () const |
DMS (int d=0, int m=0, int s=0, int ms=0) | |
Default Constructor. More... | |
DMS (int d, int m, const double &s) | |
Constructor. More... | |
DMS (const double &x) | |
Construct an angle from a double value. More... | |
DMS (const Nice::Time &_t) | |
Ctor from a time value. More... | |
bool | isValid () const |
operator double () const | |
Cast operator DMSVar (empty). More... | |
bool | operator== (const DMS &d) const |
equal ?. More... | |
int | degree () const |
int | arcmin () const |
int | arcsec () const |
int | marcsec () const |
const double & | degrees () const |
int | hour () const |
int | minute () const |
int | second () const |
int | msecond () const |
double | hours () const |
void | setDeg (int d) |
Sets integer degrees portion of angle, leaving the arcminute and arcsecond values intact. More... | |
void | setArcMin (int m) |
Sets integer arcminutes portion of angle, leaving the degrees and arcsecond values intact. More... | |
void | setArcSec (int s) |
Sets integer arcseconds portion of angle, leaving the degrees and arcminute values intact. More... | |
void | setD (const double &x) |
void | setD (int d, int m, int s, int ms) |
void | setD (int d, int m, const double &s) |
void | setHour (int h) |
Sets integer hours portion of angle, leaving the minutes and seconds values intact. More... | |
void | setHMin (int m) |
Sets integer minutes portion of angle, leaving the hours and seconds values intact. More... | |
void | setHSec (int s) |
Sets integer seconds portion of angle, leaving the hours and minutes values intact. More... | |
void | setH (const double &x) |
void | setH (int h, int m, int s, int ms) |
void | setH (int h, int m, const double &s) |
void | set (const DMS &d) |
Copy value of another DMS angle. More... | |
void | set (const double &d) |
Copy value of another DMS angle. More... | |
DMS | operator+ (DMS d) |
Addition operator. More... | |
DMS & | operator+= (const DMS &d) |
Addition operator. More... | |
DMS | operator- (DMS d) |
Subtraction operator. More... | |
DMS & | operator-= (const DMS &d) |
Subtraction operator. More... | |
void | sinCos (double &s, double &c) const |
double | sin () const |
double | cos () const |
double | radians () const |
void | setRadians (const double &a) |
double | reduce () const |
std::string | toDMSString (const bool forceSign=true) const |
std::string | toHMSString () const |
Static Public Member Functions | |
static DMS | fromString (const std::string &s) |
Static function to create a DMS object from a std::string. More... | |
static DMS | fromString (const std::string &s) |
Static function to create a DMS object from a std::string. More... | |
Static Public Attributes | |
static const double | PI = M_PI |
Euler's constant 3.14159... More... | |
static const double | DegToRad = 0.0174532925199432957692369076849 |
the conversion factor pi divided by 180. More... | |
Private Attributes | |
double | m_dms |
An angle, stored as degrees, but expressible in many ways.
DMS encapsulates an angle. The angle is stored as a double, equal to the value of the angle in degrees. Methods are available for setting/getting the angle as a floating-point measured in Degrees or Hours, or as integer triplets (degrees, arcminutes, arcseconds or hours, minutes, seconds). There is also a method to set the angle according to a radian value, and to return the angle expressed in radians. Finally, a sinCos() method computes the sin and cosine of the angle. Once computed, the sin and cos values are stored, so that subsequent sinCos() calls will be faster.
|
inline |
Default Constructor.
Set the floating-point value of the angle according to the four integer arguments.
d | degree portion of angle (int). Defaults to zero. |
m | arcminute portion of angle (int). Defaults to zero. |
s | arcsecond portion of angle (int). Defaults to zero. |
ms | arcsecond portion of angle (int). Defaults to zero. |
|
inline |
Constructor.
Set the floating-point value of the angle according to numeric arguments.
d | degree portion of angle (int). |
m | arcminute portion of angle (int). |
s | arcsecond portion of angle (double). |
|
inline |
Construct an angle from a double value.
Creates an angle whose value in Degrees is equal to the argument.
x | angle expressed as a floating-point number (in degrees) |
|
inline |
Ctor from a time value.
Creates an angle equating 24 hours in time with 360 degrees in the angle.
_t | The time value. |
|
inline |
Default Constructor.
Set the floating-point value of the angle according to the four integer arguments.
d | degree portion of angle (int). Defaults to zero. |
m | arcminute portion of angle (int). Defaults to zero. |
s | arcsecond portion of angle (int). Defaults to zero. |
ms | arcsecond portion of angle (int). Defaults to zero. |
|
inline |
Constructor.
Set the floating-point value of the angle according to numeric arguments.
d | degree portion of angle (int). |
m | arcminute portion of angle (int). |
s | arcsecond portion of angle (double). |
|
inline |
Construct an angle from a double value.
Creates an angle whose value in Degrees is equal to the argument.
x | angle expressed as a floating-point number (in degrees) |
|
inline |
Ctor from a time value.
Creates an angle equating 24 hours in time with 360 degrees in the angle.
_t | The time value. |
int Nice::DMS::arcmin | ( | ) | const |
int Nice::DMS::arcmin | ( | ) | const |
int Nice::DMS::arcsec | ( | ) | const |
int Nice::DMS::arcsec | ( | ) | const |
double Nice::DMS::cos | ( | ) | const |
double Nice::DMS::cos | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
Static function to create a DMS object from a std::string.
There are several ways to specify the angle:
s | the string to be parsed as an angle value |
Static function to create a DMS object from a std::string.
There are several ways to specify the angle:
s | the string to be parsed as an angle value |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
int Nice::DMS::marcsec | ( | ) | const |
int Nice::DMS::marcsec | ( | ) | const |
int Nice::DMS::minute | ( | ) | const |
int Nice::DMS::minute | ( | ) | const |
int Nice::DMS::msecond | ( | ) | const |
int Nice::DMS::msecond | ( | ) | const |
|
inline |
Cast operator DMSVar (empty).
|
inline |
Cast operator DMSVar (empty).
Addition operator.
Add the two angles.
d | add to current angle |
Addition operator.
Add the two angles.
d | add to current angle |
Addition operator.
Add another angle to this.
d | add to current angle |
Addition operator.
Add another angle to this.
d | add to current angle |
Subtraction operator.
Subtract two angles.
d | subtract from current angle |
Subtraction operator.
Subtract two angles.
d | subtract from current angle |
Subtraction operator.
Subtract another angle from this.
d | The angle to be subracted. |
Subtraction operator.
Subtract another angle from this.
d | The angle to be subracted. |
double Nice::DMS::radians | ( | ) | const |
Express the angle in radians.
The computed Radians value is stored internally. On subsequent calls, the stored value is returned directly (unless the angle's value has changed).
double Nice::DMS::radians | ( | ) | const |
double Nice::DMS::reduce | ( | ) | const |
return the equivalent angle between 0 and 360 degrees, in units of degrees.
double Nice::DMS::reduce | ( | ) | const |
int Nice::DMS::second | ( | ) | const |
int Nice::DMS::second | ( | ) | const |
|
inline |
|
inline |
|
inline |
Sets integer arcminutes portion of angle, leaving the degrees and arcsecond values intact.
m | new integer arcminutes value |
|
inline |
Sets integer arcminutes portion of angle, leaving the degrees and arcsecond values intact.
m | new integer arcminutes value |
|
inline |
Sets integer arcseconds portion of angle, leaving the degrees and arcminute values intact.
s | new integer arcseconds value |
|
inline |
Sets integer arcseconds portion of angle, leaving the degrees and arcminute values intact.
s | new integer arcseconds value |
void Nice::DMS::setD | ( | const double & | x | ) |
Sets floating-point value of angle, in degrees.
x | new angle (double) |
void Nice::DMS::setD | ( | const double & | x | ) |
void Nice::DMS::setD | ( | int | d, |
int | m, | ||
int | s, | ||
int | ms | ||
) |
Sets floating-point value of angle, in degrees.
This is an overloaded member function; it behaves essentially like the above function. The floating-point value of the angle (D) is determined from the following formulae:
d | integer degrees portion of angle |
m | integer arcminutes portion of angle, positive |
s | integer arcseconds portion of angle, positive |
ms | integer arcseconds portion of angle, positive |
void Nice::DMS::setD | ( | int | d, |
int | m, | ||
int | s, | ||
int | ms | ||
) |
void Nice::DMS::setD | ( | int | d, |
int | m, | ||
const double & | s | ||
) |
Sets floating-point value of angle, in degrees.
This is an overloaded member function; it behaves essentially like the above function. The floating-point value of the angle (D) is determined from the following formulae:
d | integer degrees portion of angle |
m | integer arcminutes portion of angle |
s | double arcseconds portion of angle If at least one of the three arguments is negative, the entire angle is kept negative. The main functionality of that interface definition is to express angles that are in the range from 0 to -1 deg, therefor have d=0, and need to deliver their sign by other means. |
void Nice::DMS::setD | ( | int | d, |
int | m, | ||
const double & | s | ||
) |
|
inline |
Sets integer degrees portion of angle, leaving the arcminute and arcsecond values intact.
d | new integer degrees value |
|
inline |
Sets integer degrees portion of angle, leaving the arcminute and arcsecond values intact.
d | new integer degrees value |
void Nice::DMS::setH | ( | const double & | x | ) |
void Nice::DMS::setH | ( | const double & | x | ) |
Sets floating-point value of angle, in hours.
Converts argument from hours to degrees, then sets floating-point value of angle, in degrees.
x | new angle measured in hours |
void Nice::DMS::setH | ( | int | h, |
int | m, | ||
int | s, | ||
int | ms | ||
) |
void Nice::DMS::setH | ( | int | h, |
int | m, | ||
int | s, | ||
int | ms | ||
) |
Sets floating-point value of angle, in hours.
Converts argument values from hours to degrees, then sets floating-point value of angle, in degrees.
h | integer hours portion of angle |
m | integer minutes portion of angle, positive |
s | integer seconds portion of angle, positive |
ms | integer milliseconds portion of angle, positive |
void Nice::DMS::setH | ( | int | h, |
int | m, | ||
const double & | s | ||
) |
void Nice::DMS::setH | ( | int | h, |
int | m, | ||
const double & | s | ||
) |
Sets floating-point value of angle, in hours.
Converts argument values from hours to degrees, then sets floating-point value of angle, in degrees.
h | integer hours portion of angle |
m | integer minutes portion of angle |
s | double seconds portion of angle |
|
inline |
Sets integer minutes portion of angle, leaving the hours and seconds values intact.
m | new integer minutes value |
|
inline |
Sets integer minutes portion of angle, leaving the hours and seconds values intact.
m | new integer minutes value |
|
inline |
|
inline |
|
inline |
Sets integer seconds portion of angle, leaving the hours and minutes values intact.
s | new integer seconds value |
|
inline |
Sets integer seconds portion of angle, leaving the hours and minutes values intact.
s | new integer seconds value |
void Nice::DMS::setRadians | ( | const double & | a | ) |
void Nice::DMS::setRadians | ( | const double & | Rad | ) |
Set angle according to the argument, in radians.
This function converts the argument to degrees, then sets the angle with setD().
a | angle in radians |
double Nice::DMS::sin | ( | ) | const |
double Nice::DMS::sin | ( | ) | const |
void Nice::DMS::sinCos | ( | double & | s, |
double & | c | ||
) | const |
void Nice::DMS::sinCos | ( | double & | sina, |
double & | cosa | ||
) | const |
forceSign | If true always starts the string with an explicit plus or minus. This is the standard for the declination representation in Astronomy. |
std::string Nice::DMS::toHMSString | ( | ) | const |
std::string Nice::DMS::toHMSString | ( | ) | const |
|
static |
the conversion factor pi divided by 180.
Conversion factor radians to degrees.
DegToRad is a const static member equal to the number of radians in one degree (DMS::PI/180.0 = 0.01745329).
Equals Pi/180. The inverse is 57.295779513082320876798154 .
|
private |
Euler's constant 3.14159...
Euler's constant pi=3.14159.
PI is a const static member; it's public so that it can be used anywhere, as long as DMS.h is included.
As defined in <cmath>