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

Commits on Nov 17, 2021

  1. Trace the vessels.

    pleroy committed Nov 17, 2021
    Copy the full SHA
    de6d27a View commit details

Commits on Nov 19, 2021

  1. Copy the full SHA
    2261cda View commit details
  2. Copy the full SHA
    9e5fff2 View commit details
  3. Cleanup.

    pleroy committed Nov 19, 2021
    Copy the full SHA
    3c02a6c View commit details
  4. Cleanup.

    pleroy committed Nov 19, 2021
    Copy the full SHA
    2413ed8 View commit details
  5. Copy the full SHA
    f3264f4 View commit details
  6. Merge pull request #3204 from pleroy/3203

    Properly downsample very flat trajectories
    pleroy authored Nov 19, 2021
    Copy the full SHA
    25cd8ac View commit details
3 changes: 2 additions & 1 deletion ksp_plugin/vessel.cpp
Original file line number Diff line number Diff line change
@@ -416,7 +416,8 @@ not_null<std::unique_ptr<Vessel>> Vessel::ReadFromMessage(
std::function<void(PartId)> const& deletion_callback) {
bool const is_pre_cesàro = message.has_psychohistory_is_authoritative();
bool const is_pre_chasles = message.has_prediction();
bool const is_pre_陈景润 = !message.history().has_downsampling();
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_ζήνων)
<< "Reading pre-"
4 changes: 2 additions & 2 deletions ksp_plugin_test/plugin_compatibility_test.cpp
Original file line number Diff line number Diff line change
@@ -412,8 +412,8 @@ TEST_F(PluginCompatibilityTest, DISABLED_Egg) {

// Use for debugging saves given by users.
TEST_F(PluginCompatibilityTest, DISABLED_SECULAR_Debug) {
CheckSaveCompatibility(
R"(P:\Public Mockingbird\Principia\Saves\2685\five-minute-scene-change-neptune.txt)",
not_null<std::unique_ptr<Plugin const>> plugin = ReadPluginFromFile(
R"(P:\Public Mockingbird\Principia\Saves\3203\wip.proto.b64)",
/*compressor=*/"gipfeli",
/*decoder=*/"base64");
}
3 changes: 1 addition & 2 deletions physics/discrete_trajectory_segment_body.hpp
Original file line number Diff line number Diff line change
@@ -434,8 +434,7 @@ absl::Status DiscreteTrajectorySegment<Frame>::DownsampleIfNeeded() {
}

if (right_endpoints->empty()) {
number_of_dense_points_ = timeline_.empty() ? 0 : 1;
return absl::OkStatus();
right_endpoints->push_back(std::prev(dense_iterators.end()));
}

// Obtain the times for the right endpoints. This is necessary because we
43 changes: 42 additions & 1 deletion physics/discrete_trajectory_segment_test.cpp
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ using geometry::Frame;
using geometry::Handedness;
using geometry::Inertial;
using geometry::Instant;
using geometry::Velocity;
using quantities::Abs;
using quantities::AngularFrequency;
using quantities::Length;
@@ -45,6 +46,7 @@ using testing_utilities::AppendTrajectoryTimeline;
using testing_utilities::EqualsProto;
using testing_utilities::IsNear;
using testing_utilities::NewCircularTrajectoryTimeline;
using testing_utilities::NewLinearTrajectoryTimeline;
using testing_utilities::operator""_⑴;
using ::testing::Eq;
using ::testing::Le;
@@ -237,7 +239,7 @@ TEST_F(DiscreteTrajectorySegmentTest, Evaluate) {
IsNear(10.4_⑴ * Nano(Metre / Second)));
}

TEST_F(DiscreteTrajectorySegmentTest, Downsampling) {
TEST_F(DiscreteTrajectorySegmentTest, DownsamplingCircle) {
auto const circle_segments = MakeSegments(1);
auto const downsampled_circle_segments = MakeSegments(1);
auto& circle = *circle_segments->begin();
@@ -274,6 +276,45 @@ TEST_F(DiscreteTrajectorySegmentTest, Downsampling) {
IsNear(14_⑴ * Milli(Metre / Second)));
}

TEST_F(DiscreteTrajectorySegmentTest, DownsamplingStraightLine) {
auto const line_segments = MakeSegments(1);
auto const downsampled_line_segments = MakeSegments(1);
auto& line = *line_segments->begin();
auto& downsampled_line = *downsampled_line_segments->begin();
downsampled_line.SetDownsampling(
{.max_dense_intervals = 50, .tolerance = 1 * Milli(Metre)});
auto const v = Velocity<World>({1 * Metre / Second,
2 * Metre / Second,
3 * Metre / Second});
Time const Δt = 10 * Milli(Second);
Instant const t1 = t0_;
Instant const t2 = t0_ + 10 * Second;
AppendTrajectoryTimeline(
NewLinearTrajectoryTimeline<World>(v, Δt, t1, t2),
/*to=*/line);
AppendTrajectoryTimeline(
NewLinearTrajectoryTimeline<World>(v, Δt, t1, t2),
/*to=*/downsampled_line);

EXPECT_THAT(line.size(), Eq(1001));
// In the test3200 release this used to have 1001 points, see #3203.
EXPECT_THAT(downsampled_line.size(), Eq(21));
std::vector<Length> position_errors;
std::vector<Speed> velocity_errors;
for (auto const& [time, degrees_of_freedom] : line) {
position_errors.push_back(
(downsampled_line.EvaluatePosition(time) -
degrees_of_freedom.position()).Norm());
velocity_errors.push_back(
(downsampled_line.EvaluateVelocity(time) -
degrees_of_freedom.velocity()).Norm());
}
EXPECT_THAT(*std::max_element(position_errors.begin(), position_errors.end()),
IsNear(3.6e-15_⑴ * Metre));
EXPECT_THAT(*std::max_element(velocity_errors.begin(), velocity_errors.end()),
IsNear(1.1e-14_⑴ * Metre / Second));
}

TEST_F(DiscreteTrajectorySegmentTest, DownsamplingForgetAfter) {
auto const circle_segments = MakeSegments(1);
auto const forgotten_circle_segments = MakeSegments(1);
8 changes: 4 additions & 4 deletions physics/discrete_trajectory_test.cpp
Original file line number Diff line number Diff line change
@@ -687,17 +687,17 @@ TEST_F(DiscreteTraject0ryTest, SerializationExactEndpoints) {
EXPECT_THAT(
(deserialized_degrees_of_freedom1.position() - World::origin).Norm(),
AbsoluteErrorFrom((degrees_of_freedom1.position() - World::origin).Norm(),
IsNear(0.27_⑴*Milli(Metre))));
IsNear(0.022_⑴*Milli(Metre))));
EXPECT_THAT(deserialized_degrees_of_freedom1.velocity().Norm(),
AbsoluteErrorFrom(degrees_of_freedom1.velocity().Norm(),
IsNear(82_⑴ * Milli(Metre) / Second)));
IsNear(5.8_⑴ * Milli(Metre) / Second)));
EXPECT_THAT(
(deserialized_degrees_of_freedom2.position() - World::origin).Norm(),
AbsoluteErrorFrom((degrees_of_freedom2.position() - World::origin).Norm(),
IsNear(0.19_⑴*Milli(Metre))));
IsNear(0.47_⑴*Milli(Metre))));
EXPECT_THAT(deserialized_degrees_of_freedom2.velocity().Norm(),
AbsoluteErrorFrom(degrees_of_freedom2.velocity().Norm(),
IsNear(0.36_⑴ * Metre / Second)));
IsNear(1.5_⑴ * Milli(Metre) / Second)));
}

TEST_F(DiscreteTraject0ryTest, SerializationRange) {