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: 9412bfb69a61
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1abbaa538662
Choose a head ref
  • 9 commits
  • 56 files changed
  • 1 contributor

Commits on Dec 11, 2019

  1. Start again from scratch.

    pleroy committed Dec 11, 2019
    Copy the full SHA
    deec4c0 View commit details
  2. Clean up geometry.

    pleroy committed Dec 11, 2019
    Copy the full SHA
    8efbe1a View commit details
  3. Clean up physics.

    pleroy committed Dec 11, 2019
    Copy the full SHA
    83c3ed5 View commit details
  4. Cleanup the plugin.

    pleroy committed Dec 11, 2019
    Copy the full SHA
    ba33ee0 View commit details
  5. Clean up the rest of the code.

    pleroy committed Dec 11, 2019
    Copy the full SHA
    cd65614 View commit details
  6. Merge.

    pleroy committed Dec 11, 2019
    Copy the full SHA
    34e4ab2 View commit details
  7. Minor cleanups.

    pleroy committed Dec 11, 2019
    Copy the full SHA
    1f60086 View commit details

Commits on Dec 12, 2019

  1. After egg's review.

    pleroy committed Dec 12, 2019
    Copy the full SHA
    55524c3 View commit details
  2. Merge pull request #2399 from pleroy/SimplerFrames1

    First step of simplifying and improving frames
    pleroy authored Dec 12, 2019
    Copy the full SHA
    1abbaa5 View commit details
Showing with 237 additions and 149 deletions.
  1. +8 −6 astronomy/frames.hpp
  2. +2 −1 astronomy/ksp_fingerprint_test.cpp
  3. +2 −1 astronomy/ksp_resonance_test.cpp
  4. +2 −1 astronomy/ksp_system_test.cpp
  5. +4 −2 astronomy/lunar_orbit_test.cpp
  6. +3 −2 astronomy/solar_system_dynamics_test.cpp
  7. +1 −1 benchmarks/dynamic_frame.cpp
  8. +2 −1 benchmarks/embedded_explicit_runge_kutta_nyström_integrator.cpp
  9. +2 −2 benchmarks/perspective.cpp
  10. +2 −1 benchmarks/symplectic_runge_kutta_nyström_integrator.cpp
  11. +1 −1 geometry/affine_map_test.cpp
  12. +35 −4 geometry/frame.hpp
  13. +18 −15 geometry/frame_body.hpp
  14. +20 −5 geometry/frame_test.cpp
  15. +3 −3 geometry/grassmann.hpp
  16. +3 −3 geometry/grassmann_body.hpp
  17. +1 −1 geometry/grassmann_test.cpp
  18. +2 −2 geometry/identity_test.cpp
  19. +1 −1 geometry/orthogonal_map_test.cpp
  20. +1 −1 geometry/pair_test.cpp
  21. +2 −2 geometry/permutation_test.cpp
  22. +2 −2 geometry/perspective_test.cpp
  23. +1 −1 geometry/point_test.cpp
  24. +6 −4 geometry/rotation_test.cpp
  25. +1 −1 geometry/rp2_point_test.cpp
  26. +5 −4 geometry/symmetric_bilinear_form_test.cpp
  27. +38 −17 ksp_plugin/frames.hpp
  28. +3 −1 ksp_plugin/interface.cpp
  29. +1 −4 ksp_plugin/orbit_analyser.cpp
  30. +2 −1 ksp_plugin/pile_up.hpp
  31. +1 −1 ksp_plugin_test/manœuvre_test.cpp
  32. +2 −1 mathematica/integrator_plots.cpp
  33. +1 −2 numerics/double_precision_test.cpp
  34. +2 −1 numerics/hermite3_test.cpp
  35. +2 −1 numerics/polynomial_test.cpp
  36. +4 −2 physics/apsides_test.cpp
  37. +2 −2 physics/barycentric_rotating_dynamic_frame_test.cpp
  38. +2 −2 physics/body_centred_body_direction_dynamic_frame_test.cpp
  39. +2 −2 physics/body_centred_non_rotating_dynamic_frame_test.cpp
  40. +2 −2 physics/body_surface_dynamic_frame_test.cpp
  41. +1 −1 physics/body_surface_frame_field_test.cpp
  42. +3 −2 physics/body_test.cpp
  43. +2 −1 physics/continuous_trajectory_test.cpp
  44. +2 −1 physics/discrete_trajectory_test.cpp
  45. +2 −1 physics/dynamic_frame.hpp
  46. +3 −2 physics/dynamic_frame_test.cpp
  47. +1 −2 physics/euler_solver_test.cpp
  48. +2 −1 physics/geopotential_test.cpp
  49. +1 −4 physics/hierarchical_system_body.hpp
  50. +2 −1 physics/hierarchical_system_test.cpp
  51. +5 −4 physics/inertia_tensor_test.cpp
  52. +1 −4 physics/jacobi_coordinates.hpp
  53. +2 −1 physics/jacobi_coordinates_test.cpp
  54. +6 −6 physics/massive_body_body.hpp
  55. +8 −10 physics/rigid_motion_test.cpp
  56. +2 −1 physics/solar_system_test.cpp
14 changes: 8 additions & 6 deletions astronomy/frames.hpp
Original file line number Diff line number Diff line change
@@ -13,7 +13,9 @@ namespace astronomy {
namespace internal_frames {

using geometry::Frame;
using geometry::Inertial;
using geometry::Instant;
using geometry::NonInertial;
using geometry::Position;
using quantities::si::ArcMinute;
using quantities::si::ArcSecond;
@@ -46,7 +48,7 @@ using quantities::si::Degree;
// identified with TCB), we call this ICRS.
using ICRS = Frame<serialization::Frame::SolarSystemTag,
serialization::Frame::ICRS,
/*frame_is_inertial=*/true>;
Inertial>;

// The Geocentric Celestial Reference System.
// The origin is the centre of mass of the whole Earth system, including oceans
@@ -65,7 +67,7 @@ using ICRS = Frame<serialization::Frame::SolarSystemTag,
// Principia's |Instant| is TT.
using GCRS = Frame<serialization::Frame::SolarSystemTag,
serialization::Frame::GCRS,
/*frame_is_inertial=*/false>;
NonInertial>;

// The International Terrestrial Reference System.
// The origin is the centre of mass of the whole Earth system, including oceans
@@ -98,7 +100,7 @@ using GCRS = Frame<serialization::Frame::SolarSystemTag,
// http://etrs89.ensg.ign.fr/pub/EUREF-TN-1.pdf
using ITRS = Frame<serialization::Frame::SolarSystemTag,
serialization::Frame::ITRS,
/*frame_is_inertial=*/false>;
NonInertial>;

// The following two reference systems are both geocentric, and they share the
// same z axis, the Celestial Intermediate Pole. Their common xy plane is the
@@ -141,9 +143,9 @@ using CelestialIntermediateReferenceSystem = GCRS;
// The xy plane is the plane of the sky. The origin is at the barycentre of the
// extrasolar system. The z axis goes from the extrasolar system to the Earth.
// The xz plane is (approximately) the plane of the extrasolar system.
using Sky =
Frame<serialization::Frame::SolarSystemTag,
serialization::Frame::SKY, true>;
using Sky = Frame<serialization::Frame::SolarSystemTag,
serialization::Frame::SKY,
Inertial>;

} // namespace internal_frames

3 changes: 2 additions & 1 deletion astronomy/ksp_fingerprint_test.cpp
Original file line number Diff line number Diff line change
@@ -19,14 +19,15 @@ namespace astronomy {
using base::Fingerprint2011;
using base::SerializeAsBytes;
using geometry::Frame;
using geometry::Inertial;
using physics::SolarSystem;
using ::testing::Eq;

class KSPFingerprintTest : public ::testing::Test {
protected:
using Barycentric = Frame<serialization::Frame::PluginTag,
serialization::Frame::BARYCENTRIC,
true>;
Inertial>;

KSPFingerprintTest()
: solar_system_(
3 changes: 2 additions & 1 deletion astronomy/ksp_resonance_test.cpp
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ using base::OFStream;
using geometry::AngularVelocity;
using geometry::BarycentreCalculator;
using geometry::Frame;
using geometry::Inertial;
using geometry::Instant;
using geometry::OrthogonalMap;
using geometry::Position;
@@ -73,7 +74,7 @@ class KSPResonanceTest : public ::testing::Test {
protected:
using KSP = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST,
/*frame_is_inertial=*/true>;
Inertial>;

using Periods = std::map<not_null<MassiveBody const*>, Time>;

3 changes: 2 additions & 1 deletion astronomy/ksp_system_test.cpp
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ using base::not_null;
using base::OFStream;
using geometry::BarycentreCalculator;
using geometry::Frame;
using geometry::Inertial;
using geometry::Instant;
using geometry::Position;
using geometry::Sign;
@@ -66,7 +67,7 @@ namespace astronomy {

using KSP = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST,
/*frame_is_inertial=*/true>;
Inertial>;

class KSPSystem {
protected:
6 changes: 4 additions & 2 deletions astronomy/lunar_orbit_test.cpp
Original file line number Diff line number Diff line change
@@ -45,7 +45,9 @@ using base::OFStream;
using geometry::AngularVelocity;
using geometry::Displacement;
using geometry::Frame;
using geometry::Inertial;
using geometry::Instant;
using geometry::NonInertial;
using geometry::OrthogonalMap;
using geometry::Position;
using geometry::Vector;
@@ -178,7 +180,7 @@ class LunarOrbitTest : public ::testing::TestWithParam<GeopotentialTruncation> {
// Earth, see figure 1. of Russell and Lara (2006).
using LunarSurface = Frame<LunarTag,
LunarTag::surface,
/*frame_is_inertial=*/false>;
NonInertial>;

// This reference frame is non-rotating, with its origin at the selenocentre.
// The axes are those of LunarSurface at J2000.
@@ -187,7 +189,7 @@ class LunarOrbitTest : public ::testing::TestWithParam<GeopotentialTruncation> {
// |KeplerOrbit| should check that; this is good enough for a test.
using Selenocentric = Frame<LunarTag,
LunarTag::selenocentric,
/*frame_is_inertial=*/true>;
Inertial>;

// We do not use a |BodyCentredNonRotatingDynamicFrame| since that would use
// ICRS axes.
5 changes: 3 additions & 2 deletions astronomy/solar_system_dynamics_test.cpp
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ using geometry::Commutator;
using geometry::DefinesFrame;
using geometry::Displacement;
using geometry::Frame;
using geometry::Inertial;
using geometry::Instant;
using geometry::Position;
using geometry::Rotation;
@@ -171,8 +172,8 @@ class SolarSystemDynamicsTest : public ::testing::Test {
// of the Sun's axis.
// TODO(egg): perhaps rotating bodies should export a rotation to their
// celestial reference frame, we'll use that in the plugin too.
enum LocalFrameTag { tag };
using ParentEquator = Frame<LocalFrameTag, tag, /*frame_is_inertial=*/true>;
using ParentEquator =
Frame<enum class LocalFrameTag, LocalFrameTag{}, Inertial>;
auto const z = Bivector<double, ICRS>({0, 0, 1});
std::optional<Rotation<ICRS, ParentEquator>> rotation;

2 changes: 1 addition & 1 deletion benchmarks/dynamic_frame.cpp
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ const Length tolerance = 0.01 * Metre;
} // namespace

using Rendering = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST, false>;
serialization::Frame::TEST>;

template<typename F, template<typename> class T>
void FillLinearTrajectory(Position<F> const& initial,
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ namespace principia {

using geometry::Displacement;
using geometry::Frame;
using geometry::Inertial;
using geometry::Instant;
using geometry::Position;
using geometry::Vector;
@@ -58,7 +59,7 @@ namespace integrators {
namespace {

using World = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST, true>;
serialization::Frame::TEST, Inertial>;

template<typename ODE>
double HarmonicOscillatorToleranceRatio1D(
4 changes: 2 additions & 2 deletions benchmarks/perspective.cpp
Original file line number Diff line number Diff line change
@@ -26,9 +26,9 @@ using quantities::si::Radian;

namespace {
using World = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST1, false>;
serialization::Frame::TEST1>;
using Camera = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST2, false>;
serialization::Frame::TEST2>;
} // namespace

void RandomSegmentsBenchmark(
3 changes: 2 additions & 1 deletion benchmarks/symplectic_runge_kutta_nyström_integrator.cpp
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ namespace principia {
using base::Status;
using geometry::Displacement;
using geometry::Frame;
using geometry::Inertial;
using geometry::Instant;
using geometry::Position;
using geometry::Vector;
@@ -58,7 +59,7 @@ namespace integrators {
namespace {

using World = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST, true>;
serialization::Frame::TEST, Inertial>;

} // namespace

2 changes: 1 addition & 1 deletion geometry/affine_map_test.cpp
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ using testing_utilities::RelativeError;
class AffineMapTest : public testing::Test {
protected:
using World = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST, true>;
serialization::Frame::TEST, Inertial>;

using Orth = OrthogonalMap<World, World>;
using Perm = Permutation<World, World>;
39 changes: 35 additions & 4 deletions geometry/frame.hpp
Original file line number Diff line number Diff line change
@@ -16,12 +16,40 @@ namespace internal_frame {
using base::not_constructible;
using base::not_null;

template<typename FrameTag, FrameTag frame_tag, bool frame_is_inertial>
enum FrameMotion {
Inertial,
NonInertial,
};

enum class Handedness {
Left,
Right,
};

// The frame is serializable if and only if FrameTag is a protocol buffer enum.
// To declare a local frame that does not need serialization, use the following
// pattern:
// using MyFrame = Frame<enum class MyFrameTag>;
//
// or:
// using MyFrame = Frame<enum class MyFrameTag, MyFrameTag{}, Inertial>;
//
// By default, the frame is non-inertial and right-handed.
// TODO(phl): Make the serialization check compile-time.
template<typename FrameTag,
FrameTag tag_ = FrameTag{},
FrameMotion motion_ = NonInertial,
Handedness handedness_ = Handedness::Right>
struct Frame : not_constructible {
static constexpr bool is_inertial = motion_ == Inertial;
static constexpr FrameMotion motion = motion_;
static constexpr Handedness handedness = handedness_;

static const Position<Frame> origin;
static const Velocity<Frame> unmoving;

using Tag = FrameTag;
static Position<Frame> const origin;
static Tag const tag = frame_tag;
static bool const is_inertial = frame_is_inertial;
static constexpr Tag tag = tag_;

static void WriteToMessage(not_null<serialization::Frame*> message);

@@ -38,6 +66,9 @@ void ReadFrameFromMessage(
} // namespace internal_frame

using internal_frame::Frame;
using internal_frame::Handedness;
using internal_frame::Inertial;
using internal_frame::NonInertial;
using internal_frame::ReadFrameFromMessage;

} // namespace geometry
33 changes: 18 additions & 15 deletions geometry/frame_body.hpp
Original file line number Diff line number Diff line change
@@ -20,37 +20,40 @@ inline uint32_t Fingerprint(std::string const& s) {
return Fingerprint2011(s.c_str(), s.size()) & 0xFFFFFFFF;
}

template<typename FrameTag, FrameTag frame_tag, bool frame_is_inertial>
void Frame<FrameTag, frame_tag, frame_is_inertial>::WriteToMessage(
not_null<serialization::Frame*> const message) {
template<typename FrameTag, FrameTag tag_,
FrameMotion motion_, Handedness handedness_>
void Frame<FrameTag, tag_, motion_, handedness_>::WriteToMessage(
not_null<serialization::Frame*> const message) {
std::string const& tag_type_full_name =
google::protobuf::GetEnumDescriptor<Tag>()->full_name();

message->set_tag_type_fingerprint(Fingerprint(tag_type_full_name));
message->set_tag(tag);
message->set_tag(static_cast<int>(tag));
message->set_is_inertial(is_inertial);
}

template<typename FrameTag, FrameTag frame_tag, bool frame_is_inertial>
void Frame<FrameTag, frame_tag, frame_is_inertial>::ReadFromMessage(
serialization::Frame const& message) {
template<typename FrameTag, FrameTag tag_,
FrameMotion motion_, Handedness handedness_>
void Frame<FrameTag, tag_, motion_, handedness_>::ReadFromMessage(
serialization::Frame const& message) {
std::string const& tag_type_full_name =
google::protobuf::GetEnumDescriptor<Tag>()->full_name();

CHECK_EQ(Fingerprint(tag_type_full_name), message.tag_type_fingerprint())
<< tag_type_full_name;
CHECK_EQ(tag, message.tag());
CHECK_EQ(static_cast<int>(tag), message.tag());
CHECK_EQ(is_inertial, message.is_inertial());
}

// Default-initialized to {0, 0, 0}.
template<typename FrameTag, FrameTag frame_tag, bool frame_is_inertial>
Position<Frame<FrameTag, frame_tag, frame_is_inertial>> const
Frame<FrameTag, frame_tag, frame_is_inertial>::origin;
template<typename FrameTag, FrameTag frame_tag, bool frame_is_inertial>
FrameTag const Frame<FrameTag, frame_tag, frame_is_inertial>::tag;
template<typename FrameTag, FrameTag frame_tag, bool frame_is_inertial>
bool const Frame<FrameTag, frame_tag, frame_is_inertial>::is_inertial;
template<typename FrameTag, FrameTag tag_,
FrameMotion motion_, Handedness handedness_>
Position<Frame<FrameTag, tag_, motion_, handedness_>> const
Frame<FrameTag, tag_, motion_, handedness_>::origin;
template<typename FrameTag, FrameTag tag_,
FrameMotion motion_, Handedness handedness_>
Velocity<Frame<FrameTag, tag_, motion_, handedness_>> const
Frame<FrameTag, tag_, motion_, handedness_>::unmoving;

inline void ReadFrameFromMessage(
serialization::Frame const& message,
25 changes: 20 additions & 5 deletions geometry/frame_test.cpp
Original file line number Diff line number Diff line change
@@ -12,13 +12,28 @@ namespace geometry {
class FrameTest : public testing::Test {
protected:
using World1 = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST1, true>;
serialization::Frame::TEST1,
Inertial,
Handedness::Right>;
using World2 = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST2, true>;
serialization::Frame::TEST2,
Inertial,
Handedness::Right>;
using World3 = Frame<serialization::Frame::TestTag,
serialization::Frame::TEST1, false>;
serialization::Frame::TEST1,
NonInertial,
Handedness::Right>;
using World4 = Frame<serialization::Frame::SolarSystemTag,
serialization::Frame::ICRS, true>;
serialization::Frame::ICRS,
Inertial,
Handedness::Right>;

using F1 = Frame<enum class F1Tag>;
using F2 = Frame<enum class F2Tag>;
using F3 = Frame<enum class F3Tag, F3Tag{}, Inertial>;
static_assert(!std::is_same_v<F1, F2>);
static_assert(!std::is_same_v<F1, F3>);
static_assert(!std::is_same_v<F2, F3>);
};

using FrameDeathTest = FrameTest;
@@ -28,7 +43,7 @@ TEST_F(FrameDeathTest, SerializationError) {
serialization::Frame message;
World1::WriteToMessage(&message);
World2::ReadFromMessage(message);
}, "tag ==");
}, R"(\(tag\) ==)");
EXPECT_DEATH({
serialization::Frame message;
World1::WriteToMessage(&message);
6 changes: 3 additions & 3 deletions geometry/grassmann.hpp
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ class Multivector;
template<typename Scalar, typename Frame>
class Multivector<Scalar, Frame, 1> final {
public:
Multivector();
constexpr Multivector();
explicit Multivector(R3Element<Scalar> const& coordinates);

R3Element<Scalar> const& coordinates() const;
@@ -77,7 +77,7 @@ class Multivector<Scalar, Frame, 1> final {
template<typename Scalar, typename Frame>
class Multivector<Scalar, Frame, 2> final {
public:
Multivector();
constexpr Multivector();
explicit Multivector(R3Element<Scalar> const& coordinates);

R3Element<Scalar> const& coordinates() const;
@@ -111,7 +111,7 @@ class Multivector<Scalar, Frame, 2> final {
template<typename Scalar, typename Frame>
class Multivector<Scalar, Frame, 3> final {
public:
Multivector();
constexpr Multivector();
explicit Multivector(Scalar const& coordinates);

Scalar const& coordinates() const;
Loading