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

Commits on Nov 20, 2021

  1. Ζήνων is Hamilton.

    pleroy committed Nov 20, 2021
    Copy the full SHA
    4be475f View commit details
  2. Lint.

    pleroy committed Nov 20, 2021
    Copy the full SHA
    5d43e41 View commit details
  3. Merge pull request #3209 from pleroy/Zenon

    Ζήνων is Hamilton
    pleroy authored Nov 20, 2021
    Copy the full SHA
    22a36f2 View commit details
8 changes: 4 additions & 4 deletions ksp_plugin/part.cpp
Original file line number Diff line number Diff line change
@@ -262,14 +262,14 @@ not_null<std::unique_ptr<Part>> Part::ReadFromMessage(
is_pre_fréchet || (message.has_pre_frenet_inertia_tensor() &&
!message.has_intrinsic_torque());
bool const is_pre_galileo = !message.has_centre_of_mass();
bool const is_pre_ζήνων = message.prehistory().segment_size() == 0;
LOG_IF(WARNING, is_pre_ζήνων)
bool const is_pre_hamilton = message.prehistory().segment_size() == 0;
LOG_IF(WARNING, is_pre_hamilton)
<< "Reading pre-"
<< (is_pre_cesàro ? u8"Cesàro"
: is_pre_fréchet ? u8"Fréchet"
: is_pre_frenet ? "Frenet"
: is_pre_galileo ? "Galileo"
: u8"Ζήνων") << " Part";
: "Hamilton") << " Part";

std::unique_ptr<Part> part;
if (is_pre_fréchet) {
@@ -336,7 +336,7 @@ not_null<std::unique_ptr<Part>> Part::ReadFromMessage(
part->AppendToHistory(time, degrees_of_freedom);
}
}
} else if (is_pre_ζήνων) {
} else if (is_pre_hamilton) {
DiscreteTrajectorySegmentIterator<Barycentric> history;
DiscreteTrajectorySegmentIterator<Barycentric> psychohistory;
auto prehistory = DiscreteTrajectory<Barycentric>::ReadFromMessage(
8 changes: 4 additions & 4 deletions ksp_plugin/pile_up.cpp
Original file line number Diff line number Diff line change
@@ -219,14 +219,14 @@ not_null<std::unique_ptr<PileUp>> PileUp::ReadFromMessage(
message.apparent_part_degrees_of_freedom_size() > 0;
bool const is_pre_frobenius = message.rigid_pile_up().empty() ||
!message.has_angular_momentum();
bool const is_pre_ζήνων = message.history().segment_size() == 0;
LOG_IF(WARNING, is_pre_ζήνων)
bool const is_pre_hamilton = message.history().segment_size() == 0;
LOG_IF(WARNING, is_pre_hamilton)
<< "Reading pre-"
<< (is_pre_cartan ? "Cartan"
: is_pre_cesàro ? u8"Cesàro"
: is_pre_frege ? "Frege"
: is_pre_frobenius ? "Frobenius"
: u8"Ζήνων") << " PileUp";
: "Hamilton") << " PileUp";

std::unique_ptr<PileUp> pile_up;
if (is_pre_cesàro) {
@@ -292,7 +292,7 @@ not_null<std::unique_ptr<PileUp>> PileUp::ReadFromMessage(
/*angular_momentum=*/{},
ephemeris,
std::move(deletion_callback)));
} else if (is_pre_ζήνων) {
} else if (is_pre_hamilton) {
DiscreteTrajectorySegmentIterator<Barycentric> psychohistory;
auto trajectory = DiscreteTrajectory<Barycentric>::ReadFromMessage(
message.history(),
8 changes: 4 additions & 4 deletions ksp_plugin/vessel.cpp
Original file line number Diff line number Diff line change
@@ -418,13 +418,13 @@ not_null<std::unique_ptr<Vessel>> Vessel::ReadFromMessage(
bool const is_pre_chasles = message.has_prediction();
bool const is_pre_陈景润 = !message.history().has_downsampling() &&
message.history().segment_size() == 0;
bool const is_pre_ζήνων = message.history().segment_size() == 0;
LOG_IF(WARNING, is_pre_ζήνων)
bool const is_pre_hamilton = message.history().segment_size() == 0;
LOG_IF(WARNING, is_pre_hamilton)
<< "Reading pre-"
<< (is_pre_cesàro ? u8"Cesàro"
: is_pre_chasles ? "Chasles"
: is_pre_陈景润 ? u8"陈景润"
: u8"Ζήνων") << " Vessel";
: "Hamilton") << " Vessel";

// NOTE(egg): for now we do not read the |MasslessBody| as it can contain no
// information.
@@ -475,7 +475,7 @@ not_null<std::unique_ptr<Vessel>> Vessel::ReadFromMessage(
/*tracked=*/{&vessel->psychohistory_});
vessel->history_ = vessel->trajectory_.segments().begin();
vessel->prediction_ = vessel->trajectory_.NewSegment();
} else if (is_pre_ζήνων) {
} else if (is_pre_hamilton) {
vessel->trajectory_ = DiscreteTrajectory<Barycentric>::ReadFromMessage(
message.history(),
/*tracked=*/{&vessel->psychohistory_, &vessel->prediction_});
4 changes: 2 additions & 2 deletions ksp_plugin_test/plugin_compatibility_test.cpp
Original file line number Diff line number Diff line change
@@ -330,7 +330,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
/*compressor=*/"gipfeli",
/*decoder=*/"base64");
EXPECT_THAT(log_warning.string(),
AllOf(HasSubstr(u8"pre-Ζήνων"), Not(HasSubstr("pre-Haar"))));
AllOf(HasSubstr("pre-Hamilton"), Not(HasSubstr("pre-Haar"))));

// The vessel with the longest history.
auto const& vessel =
@@ -395,7 +395,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Egg) {
/*compressor=*/"gipfeli",
/*decoder=*/"base64");
EXPECT_THAT(log_warning.string(),
AllOf(HasSubstr(u8"pre-Ζήνων"), Not(HasSubstr("pre-Haar"))));
AllOf(HasSubstr("pre-Hamilton"), Not(HasSubstr("pre-Haar"))));

auto& mutable_plugin = const_cast<Plugin&>(*plugin);

14 changes: 7 additions & 7 deletions physics/discrete_trajectory.hpp
Original file line number Diff line number Diff line change
@@ -167,26 +167,26 @@ class DiscreteTrajectory : public Trajectory<Frame> {
DiscreteTrajectory& to,
typename Segments::iterator to_segments_begin);

// Reads a pre-Ζήνων downsampling message and return the downsampling
// Reads a pre-Hamilton downsampling message and return the downsampling
// parameters and the start of the dense timeline. The latter will have to be
// converted to a number of points based on the deserialized timeline.
static void ReadFromPreΖήνωνMessage(
static void ReadFromPreHamiltonMessage(
serialization::DiscreteTrajectory::Downsampling const& message,
DownsamplingParameters& downsampling_parameters,
Instant& start_of_dense_timeline);

// Reads a set of pre-Ζήνων children. Checks that there is only one child,
// Reads a set of pre-Hamilton children. Checks that there is only one child,
// and that it is at the end of the preceding segment. Append a segment to
// the trajectory and returns an iterator to that segment.
static SegmentIterator ReadFromPreΖήνωνMessage(
static SegmentIterator ReadFromPreHamiltonMessage(
serialization::DiscreteTrajectory::Brood const& message,
std::vector<SegmentIterator*> const& tracked,
value_type const& fork_point,
DiscreteTrajectory& trajectory);

// Reads a pre-Ζήνων trajectory, updating the tracked segments as needed. If
// this is not the root of the trajectory, fork_point is set.
static void ReadFromPreΖήνωνMessage(
// Reads a pre-Hamilton trajectory, updating the tracked segments as needed.
// If this is not the root of the trajectory, fork_point is set.
static void ReadFromPreHamiltonMessage(
serialization::DiscreteTrajectory const& message,
std::vector<SegmentIterator*> const& tracked,
std::optional<value_type> const& fork_point,
46 changes: 23 additions & 23 deletions physics/discrete_trajectory_body.hpp
Original file line number Diff line number Diff line change
@@ -516,10 +516,11 @@ DiscreteTrajectory<Frame>::ReadFromMessage(
std::vector<SegmentIterator*> const& tracked) {
DiscreteTrajectory trajectory(uninitialized);

bool const is_pre_ζήνων = message.segment_size() == 0;
if (is_pre_ζήνων) {
LOG_IF(WARNING, is_pre_ζήνων) << u8"Reading pre-Ζήνων DiscreteTrajectory";
ReadFromPreΖήνωνMessage(
bool const is_pre_hamilton = message.segment_size() == 0;
if (is_pre_hamilton) {
LOG_IF(WARNING, is_pre_hamilton)
<< "Reading pre-Hamilton DiscreteTrajectory";
ReadFromPreHamiltonMessage(
message, tracked, /*fork_point=*/std::nullopt, trajectory);
CHECK_OK(trajectory.ConsistencyStatus());
return trajectory;
@@ -728,7 +729,7 @@ void DiscreteTrajectory<Frame>::AdjustAfterSplicing(
}

template<typename Frame>
void DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(
void DiscreteTrajectory<Frame>::ReadFromPreHamiltonMessage(
serialization::DiscreteTrajectory::Downsampling const& message,
DownsamplingParameters& downsampling_parameters,
Instant& start_of_dense_timeline) {
@@ -750,7 +751,7 @@ void DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(

template<typename Frame>
DiscreteTrajectorySegmentIterator<Frame>
DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(
DiscreteTrajectory<Frame>::ReadFromPreHamiltonMessage(
serialization::DiscreteTrajectory::Brood const& message,
std::vector<SegmentIterator*> const& tracked,
value_type const& fork_point,
@@ -763,15 +764,15 @@ DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(
// Keep an iterator to the last segment to be able to return a segment
// iterator.
auto sit = --trajectory.segments_->end();
ReadFromPreΖήνωνMessage(
ReadFromPreHamiltonMessage(
message.trajectories(0), tracked, fork_point, trajectory);
++sit;

return SegmentIterator(trajectory.segments_.get(), sit);
}

template<typename Frame>
void DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(
void DiscreteTrajectory<Frame>::ReadFromPreHamiltonMessage(
serialization::DiscreteTrajectory const& message,
std::vector<SegmentIterator*> const& tracked,
std::optional<value_type> const& fork_point,
@@ -796,9 +797,9 @@ void DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(
if (message.has_downsampling()) {
DownsamplingParameters downsampling_parameters;
Instant start_of_dense_timeline;
ReadFromPreΖήνωνMessage(message.downsampling(),
downsampling_parameters,
start_of_dense_timeline);
ReadFromPreHamiltonMessage(message.downsampling(),
downsampling_parameters,
start_of_dense_timeline);
sit->SetDownsamplingUnconditionally(downsampling_parameters);
sit->SetStartOfDenseTimeline(start_of_dense_timeline);
}
@@ -814,9 +815,9 @@ void DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(
DownsamplingParameters downsampling_parameters;
Instant start_of_dense_timeline;
if (message.has_downsampling()) {
ReadFromPreΖήνωνMessage(message.downsampling(),
downsampling_parameters,
start_of_dense_timeline);
ReadFromPreHamiltonMessage(message.downsampling(),
downsampling_parameters,
start_of_dense_timeline);
auto* const serialized_downsampling_parameters =
serialized_segment.mutable_downsampling_parameters();
serialized_downsampling_parameters->set_max_dense_intervals(
@@ -838,11 +839,10 @@ void DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(

// Restore the (single) child as the next segment.
if (message.children_size() == 1) {
auto const child =
ReadFromPreΖήνωνMessage(message.children(0),
tracked,
/*fork_point=*/*sit->rbegin(),
trajectory);
auto const child = ReadFromPreHamiltonMessage(message.children(0),
tracked,
/*fork_point=*/*sit->rbegin(),
trajectory);

// There were no fork positions prior to Буняковский.
bool const has_fork_position = message.fork_position_size() > 0;
@@ -862,10 +862,10 @@ void DiscreteTrajectory<Frame>::ReadFromPreΖήνωνMessage(
if (!sit->empty()) {
// This is the *only* place where we must use |emplace|, not
// |insert_or_assign|. The reason is that this happens when returning from
// the recursivity (see to the call to ReadFromPreΖήνωνMessage) so segments
// are processed in reverse order. Therefore, a segment that is the last at
// its time will be processed *before* any 1-point segments with the same
// time, and must be the one stored in the map.
// the recursivity (see to the call to ReadFromPreHamiltonMessage) so
// segments are processed in reverse order. Therefore, a segment that is
// the last at its time will be processed *before* any 1-point segments with
// the same time, and must be the one stored in the map.
trajectory.segment_by_left_endpoint_.emplace(sit->begin()->time, sit);
}
}
8 changes: 4 additions & 4 deletions physics/discrete_trajectory_test.cpp
Original file line number Diff line number Diff line change
@@ -724,7 +724,7 @@ TEST_F(DiscreteTrajectoryTest, SerializationRange) {
EXPECT_THAT(message1, EqualsProto(message2));
}

TEST_F(DiscreteTrajectoryTest, DISABLED_SerializationPreΖήνωνCompatibility) {
TEST_F(DiscreteTrajectoryTest, DISABLED_SerializationPreHamiltonCompatibility) {
StringLogSink log_warning(google::WARNING);
auto const serialized_message = ReadFromBinaryFile(
R"(P:\Public Mockingbird\Principia\Saves\3136\trajectory_3136.proto.bin)"); // NOLINT
@@ -734,9 +734,9 @@ TEST_F(DiscreteTrajectoryTest, DISABLED_SerializationPreΖήνωνCompatibility)
auto const history = DiscreteTrajectory<World>::ReadFromMessage(
message1, /*tracked=*/{&psychohistory});
EXPECT_THAT(log_warning.string(),
AllOf(HasSubstr("pre-Ζήνων"), Not(HasSubstr("pre-Haar"))));
AllOf(HasSubstr("pre-Hamilton"), Not(HasSubstr("pre-Haar"))));

// Note that the sizes don't have the same semantics as pre-Ζήνων. The
// Note that the sizes don't have the same semantics as pre-Hamilton. The
// history now counts all segments. The psychohistory has a duplicated point
// at the beginning.
EXPECT_EQ(435'929, history.size());
@@ -764,7 +764,7 @@ TEST_F(DiscreteTrajectoryTest, DISABLED_SerializationPreΖήνωνCompatibility)
+2.61488327506437054e+04 * (Metre / Second),
+1.90319283138508908e+04 * (Metre / Second)}))));

// Serialize the trajectory in the Ζήνων format.
// Serialize the trajectory in the Hamilton format.
serialization::DiscreteTrajectory message2;
history.WriteToMessage(&message2,
/*tracked=*/{psychohistory},
8 changes: 4 additions & 4 deletions serialization/physics.proto
Original file line number Diff line number Diff line change
@@ -102,8 +102,8 @@ message DiscreteTrajectory {
// Added in Haar.
repeated DiscreteTrajectorySegment.InstantaneousDegreesOfFreedom exact = 6;

// All the declarations above are pre-Ζήνων. All the declarations below were
// added in Ζήνων.
// All the declarations above are pre-Hamilton. All the declarations below
// were added in Hamilton.

// A marker to indicate that a segment doesn't have its position tracked.
enum TrackedPosition {
@@ -118,8 +118,8 @@ message DiscreteTrajectory {
repeated int32 tracked_position = 9;
}

// Added in Ζήνων. Note that some nested messages are shared with the pre-Ζήνων
// DiscreteTrajectory and must therefore remain compatible.
// Added in Hamilton. Note that some nested messages are shared with the
// pre-Hamilton DiscreteTrajectory and must therefore remain compatible.
message DiscreteTrajectorySegment {
message DownsamplingParameters {
required int64 max_dense_intervals = 1;