perturb 1.0.0
A modern C++11 wrapper for the SGP4 orbit propagator
|
Represents a specific point in time on the Julian calendar. More...
#include <perturb.hpp>
Public Member Functions | |
JulianDate () | |
Construct an empty julian date initialized to 0. | |
JulianDate (double jd) | |
Construct from a Julian number of days since epoch (4713 B.C.) | |
JulianDate (double jd, double jd_frac) | |
Construct from a Julian day number and fractional day. More... | |
JulianDate (DateTime t) | |
Construct from a DateTime time point. More... | |
DateTime | to_datetime () const |
Convert to a DateTime representing the same time point. More... | |
void | normalize () |
Normalizes a Julian date representation to a canonical representation. More... | |
JulianDate | normalized () const |
Get a normalized copy of a julian date. | |
double | operator- (const JulianDate &rhs) const |
Returns the difference/delta in times as a fractional number of days. | |
JulianDate | operator+ (const double &delta_jd) const |
Returns another time point offset by a number of days. More... | |
JulianDate & | operator+= (const double &delta_jd) |
Add a delta number of days offset to this time point. | |
JulianDate | operator- (const double &delta_jd) const |
Returns another time point offset backwards by a number of days. | |
JulianDate & | operator-= (const double &delta_jd) |
Subtracts a delta number of days offset to this time point. | |
bool | operator< (const JulianDate &rhs) const |
Compare if chronologically earlier than another time point. | |
bool | operator> (const JulianDate &rhs) const |
Compare if chronologically after than another time point. | |
bool | operator<= (const JulianDate &rhs) const |
Compare if earlier than or same as another time point. | |
bool | operator>= (const JulianDate &rhs) const |
Compare if after than or same as another time point. | |
Public Attributes | |
double | jd |
Fractional number of days since the epoch (4713 B.C.) | |
double | jd_frac |
Smaller fractional number of days. | |
Represents a specific point in time on the Julian calendar.
Generally not constructed manually, but instead converted from a DateTime
or from Satellite::epoch
. Supports some basic manipulation operations. For a human readable representation, can be converted back to DateTime
. As for what time point this represents, see the comment on DateTime
.
Internally, this is represented as the "theoretical" sum of two double precision floats. This is to preserve as much time accuracy as possible, since many bits are lost due to storing the number of the day. The smaller value is used to represent a more accurate time offset from that day. The "normalized" value restricts the larger value to entire days and the smaller to a [0.0, 1.0) time offset.
|
explicit |
Construct from a Julian day number and fractional day.
The "true" Julian date value is the sum of the two. The motivation for separating into two parts is to preserve floating-point precision.
jd | Larger Julian day value since epoch |
jd_frac | Smaller fractional Julian day value |
|
explicit |
Construct from a DateTime
time point.
t | Time point, must be from 1900 to 2100 |
void perturb::JulianDate::normalize | ( | ) |
Normalizes a Julian date representation to a canonical representation.
Modifies the two julian day values to restrict the larger value to whole days and the smaller value to a [0.0, 1.0) time offset. This is not needed for the conversions as they will automatically normalize, but you may want to do this for other reasons.
JulianDate perturb::JulianDate::operator+ | ( | const double & | delta_jd | ) | const |
Returns another time point offset by a number of days.
Offset is only added to jd_frac
, so the returned value may not be "normalized". This needs to be done explicitly if desired. This could split delta_jd
into a whole and fractional part and then add each accordingly, but I defaulted to the former method for performance. If you think this wasn't the right move, lemme know.
delta_jd | Number of fractional days to add |
DateTime perturb::JulianDate::to_datetime | ( | ) | const |
Convert to a DateTime
representing the same time point.