Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bf23d3da77c0
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7e540e05b822
Choose a head ref
  • 8 commits
  • 41 files changed
  • 1 contributor

Commits on May 9, 2017

  1. Copy the full SHA
    5bbd6d8 View commit details
  2. Data files.

    pleroy committed May 9, 2017
    Copy the full SHA
    35e343d View commit details

Commits on May 10, 2017

  1. Game configuration and tools.

    pleroy committed May 10, 2017
    Copy the full SHA
    a127263 View commit details

Commits on May 11, 2017

  1. Fix tests.

    pleroy committed May 11, 2017
    Copy the full SHA
    ad8fa91 View commit details
  2. Befriend the parser.

    pleroy committed May 11, 2017
    Copy the full SHA
    c40d074 View commit details
  3. After egg's review.

    pleroy committed May 11, 2017
    Copy the full SHA
    ee71ec6 View commit details
  4. Lint.

    pleroy committed May 11, 2017
    Copy the full SHA
    d8724b2 View commit details
  5. Merge pull request #1363 from pleroy/1355

    Construct the plugin with date literals
    pleroy authored May 11, 2017
    Copy the full SHA
    7e540e0 View commit details
Showing with 244 additions and 211 deletions.
  1. +2 −0 astronomy/date_time.hpp
  2. +21 −11 astronomy/date_time_body.hpp
  3. +0 −6 astronomy/epoch.hpp
  4. +0 −9 astronomy/epoch_body.hpp
  5. +1 −1 astronomy/generate_initial_state.awk
  6. +17 −17 astronomy/kerbol_gravity_model.proto.txt
  7. +1 −1 astronomy/kerbol_initial_state_0_0.proto.txt
  8. +34 −34 astronomy/sol_gravity_model.cfg
  9. +34 −34 astronomy/sol_gravity_model.proto.txt
  10. +1 −1 astronomy/sol_initial_state_jd_2433282_500000000.cfg
  11. +1 −1 astronomy/sol_initial_state_jd_2433282_500000000.proto.txt
  12. +1 −1 astronomy/sol_initial_state_jd_2433292_500000000.proto.txt
  13. +1 −1 astronomy/sol_initial_state_jd_2433374_257884090.proto.txt
  14. +1 −1 astronomy/sol_initial_state_jd_2433374_470754460.proto.txt
  15. +1 −1 astronomy/sol_initial_state_jd_2436116_311504629.proto.txt
  16. +1 −1 astronomy/sol_initial_state_jd_2436145_604166667.proto.txt
  17. +1 −1 astronomy/sol_initial_state_jd_2451545_000000000.proto.txt
  18. +1 −1 astronomy/sol_initial_state_jd_2451564_587154910.proto.txt
  19. +1 −1 astronomy/sol_initial_state_jd_2451564_808127140.proto.txt
  20. +1 −1 astronomy/sol_initial_state_jd_2455200_500000000.proto.txt
  21. +1 −1 astronomy/test_gravity_model_two_bodies.proto.txt
  22. +1 −1 astronomy/test_initial_state_two_bodies_circular.proto.txt
  23. +1 −1 astronomy/test_initial_state_two_bodies_elliptical.proto.txt
  24. +11 −0 astronomy/time_scales.hpp
  25. +17 −0 astronomy/time_scales_body.hpp
  26. +2 −2 journal/player_test.cpp
  27. +1 −1 journal/recorder_test.cpp
  28. +7 −5 ksp_plugin/interface.cpp
  29. +7 −6 ksp_plugin/plugin.cpp
  30. +3 −2 ksp_plugin/plugin.hpp
  31. +3 −5 ksp_plugin_adapter/ksp_plugin_adapter.cs
  32. +6 −6 ksp_plugin_test/interface_test.cpp
  33. +1 −1 ksp_plugin_test/mock_plugin.cpp
  34. +25 −20 ksp_plugin_test/plugin_integration_test.cpp
  35. +20 −14 ksp_plugin_test/plugin_test.cpp
  36. +4 −3 physics/solar_system_body.hpp
  37. +4 −4 serialization/astronomy.proto
  38. +1 −1 serialization/journal.proto
  39. +3 −7 tools/generate_configuration.cpp
  40. +1 −3 tools/generate_configuration.hpp
  41. +4 −4 tools/main.cpp
2 changes: 2 additions & 0 deletions astronomy/date_time.hpp
Original file line number Diff line number Diff line change
@@ -68,6 +68,8 @@ class Time final {
int const minute_;
int const second_;
int const millisecond_;

friend class TimeParser;
};

class DateTime final {
32 changes: 21 additions & 11 deletions astronomy/date_time_body.hpp
Original file line number Diff line number Diff line change
@@ -277,14 +277,25 @@ constexpr bool Time::is_end_of_day() const {
return hour_ == 24;
}

// Note that millisecond == 1000 can happen for JD and MJD because of rounding.
constexpr Time::Time(int const hour,
int const minute,
int const second,
int const millisecond)
: hour_(hour),
minute_(minute),
second_(second),
millisecond_(millisecond) {}
: hour_(millisecond == 1000 && second == 59 && minute == 59
? hour + 1
: hour),
minute_(millisecond == 1000 && second == 59
? minute == 59
? 0
: minute + 1
: minute),
second_(millisecond == 1000
? second == 59
? 0
: second + 1
: second),
millisecond_(millisecond % 1000) {}

constexpr Time const& Time::checked() const {
return CHECKING(
@@ -825,13 +836,12 @@ constexpr Time TimeParser::JDFractionToTime(std::int64_t const digits,
// Note that this results in rounding to the nearest millisecond.
return CHECKING(
digit_count <= 14,
Time::hhmmss_ms(
1'00'00 * digit_range(24 * digits, digit_count, digit_count + 2) +
1'00 * digit_range(60 * digit_range(24 * digits, 0, digit_count),
digit_count, digit_count + 2) +
digit_range(60 * digit_range(60 * 24 * digits, 0, digit_count),
digit_count, digit_count + 2),
JDRoundedMilliseconds(digits, digit_count)));
Time(digit_range(24 * digits, digit_count, digit_count + 2),
digit_range(60 * digit_range(24 * digits, 0, digit_count),
digit_count, digit_count + 2),
digit_range(60 * digit_range(60 * 24 * digits, 0, digit_count),
digit_count, digit_count + 2),
JDRoundedMilliseconds(digits, digit_count)).checked());
}

constexpr int TimeParser::JDRoundedMilliseconds(std::int64_t const digits,
6 changes: 0 additions & 6 deletions astronomy/epoch.hpp
Original file line number Diff line number Diff line change
@@ -36,24 +36,18 @@ CONSTEXPR_INFINITY Instant InfiniteFuture = J2000 + Infinity<Time>();
// The Julian Date JD |days|. J2000.0 is JD 2451545.0. |days| is the number of
// days since -4712-01-01T12:00:00,000 (Terrestrial Time, Julian calendar).
constexpr Instant JulianDate(double days);
// TODO(phl): Remove as part of #1355.
constexpr double JulianDayNumber(Instant const& t);

// The Modified Julian Date MJD |days|. MJD is defined as JD - 2400000.5 days,
// so |ModifiedJulianDate(0)| is "1858-11-17T00:00:00"_TT.
constexpr Instant ModifiedJulianDate(double days);
// TODO(phl): Remove as part of #1355.
constexpr double ModifiedJulianDayNumber(Instant const& t);

} // namespace internal_epoch

using internal_epoch::InfiniteFuture;
using internal_epoch::InfinitePast;
using internal_epoch::J2000;
using internal_epoch::JulianDate;
using internal_epoch::JulianDayNumber;
using internal_epoch::ModifiedJulianDate;
using internal_epoch::ModifiedJulianDayNumber;

} // namespace astronomy
} // namespace principia
9 changes: 0 additions & 9 deletions astronomy/epoch_body.hpp
Original file line number Diff line number Diff line change
@@ -9,23 +9,14 @@ namespace internal_epoch {

using quantities::si::Day;


constexpr Instant JulianDate(double const days) {
return J2000 + (days - 2451545.0) * Day;
}

constexpr double JulianDayNumber(Instant const& t) {
return 2451545.0 + (t - J2000) / Day;
}

constexpr Instant ModifiedJulianDate(double const days) {
return J2000 + (days - 51544.5) * Day;
}

constexpr double ModifiedJulianDayNumber(Instant const& t) {
return 51544.5 + (t - J2000) / Day;
}

} // namespace internal_epoch
} // namespace astronomy
} // namespace principia
2 changes: 1 addition & 1 deletion astronomy/generate_initial_state.awk
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ BEGIN {
END {
print " # The time of the initial state, as a TDB Julian date."
print " # This is " humandate " TDB."
print " epoch : " juliandate
print " epoch : \"JD" juliandate "\""
print " cartesian {"

# The year is 2015 and I am writing a Bubble Sort. I kid you not.
34 changes: 17 additions & 17 deletions astronomy/kerbol_gravity_model.proto.txt
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ gravity_model {
body {
name : "Sun"
gravitational_parameter : "1.17233279483249e+18 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "261600000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -13,7 +13,7 @@ gravity_model {
body {
name : "Eeloo"
gravitational_parameter : "74410814527.0496 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "210000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -23,7 +23,7 @@ gravity_model {
body {
name : "Jool"
gravitational_parameter : "282528004209995 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "6000000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -33,7 +33,7 @@ gravity_model {
body {
name : "Pol"
gravitational_parameter : "721702080 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "44000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -43,7 +43,7 @@ gravity_model {
body {
name : "Bop"
gravitational_parameter : "2486834944.41491 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "65000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -53,7 +53,7 @@ gravity_model {
body {
name : "Tylo"
gravitational_parameter : "2825280042099.95 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "600000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -63,7 +63,7 @@ gravity_model {
body {
name : "Vall"
gravitational_parameter : "207481499473.751 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "300000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -73,7 +73,7 @@ gravity_model {
body {
name : "Laythe"
gravitational_parameter : "1962000029236.08 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "500000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -83,7 +83,7 @@ gravity_model {
body {
name : "Dres"
gravitational_parameter : "21484488600 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "138000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -93,7 +93,7 @@ gravity_model {
body {
name : "Duna"
gravitational_parameter : "301363211975.098 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "320000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -103,7 +103,7 @@ gravity_model {
body {
name : "Ike"
gravitational_parameter : "18568368573.144 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "130000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -113,7 +113,7 @@ gravity_model {
body {
name : "Kerbin"
gravitational_parameter : "3531600000000 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "600000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -123,7 +123,7 @@ gravity_model {
body {
name : "Minmus"
gravitational_parameter : "1765800026.31247 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "60000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -133,7 +133,7 @@ gravity_model {
body {
name : "Mun"
gravitational_parameter : "65138397520.7807 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "200000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -143,7 +143,7 @@ gravity_model {
body {
name : "Eve"
gravitational_parameter : "8171730229210.87 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "700000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -153,7 +153,7 @@ gravity_model {
body {
name : "Gilly"
gravitational_parameter : "8289449.81471635 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "13000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
@@ -163,7 +163,7 @@ gravity_model {
body {
name : "Moho"
gravitational_parameter : "168609378654.509 m^3/s^2"
reference_instant : 2451545.000000000
reference_instant : "JD2451545.000000000"
mean_radius : "250000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
2 changes: 1 addition & 1 deletion astronomy/kerbol_initial_state_0_0.proto.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This system is for KSP 1.2.2.
initial_state {
epoch : 2451545.000000000 # J2000, corresponds to Instant{}.
epoch : "JD2451545.000000000" # J2000, corresponds to Instant{}.
keplerian {
body {
name : "Sun"
Loading