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

Commits on Aug 14, 2021

  1. Restore checks present at master.

    # Conflicts:
    #	physics/discrete_trajectory_body.hpp
    pleroy committed Aug 14, 2021
    Copy the full SHA
    197eca7 View commit details
  2. Copy the full SHA
    93c98f6 View commit details
  3. Reorder methods.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    ee762c5 View commit details
  4. Simplify ForgetAfter.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    025bf5c View commit details
  5. Pass inserted iterator and a misordered include.

    # Conflicts:
    #	physics/discrete_trajectory.hpp
    pleroy committed Aug 14, 2021
    Copy the full SHA
    d018ed8 View commit details
  6. Append and ForgetAfter.

    # Conflicts:
    #	physics/discrete_trajectory.hpp
    pleroy committed Aug 14, 2021
    Copy the full SHA
    afface7 View commit details
  7. ForgetBefore.

    # Conflicts:
    #	physics/discrete_trajectory.hpp
    pleroy committed Aug 14, 2021
    Copy the full SHA
    d054f23 View commit details
  8. Construction and writing.

    # Conflicts:
    #	serialization/physics.proto
    pleroy committed Aug 14, 2021
    Copy the full SHA
    d25a267 View commit details
  9. ExtractIfFull

    pleroy committed Aug 14, 2021
    Copy the full SHA
    0320460 View commit details
  10. Change all the things.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    9b4d183 View commit details
  11. One test passing.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    f78d4f2 View commit details
  12. Deserialization.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    d212eab View commit details
  13. Comments.

    # Conflicts:
    #	physics/discrete_trajectory.hpp
    pleroy committed Aug 14, 2021
    Copy the full SHA
    7b87acb View commit details
  14. Post-cherrypick.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    2cc11c7 View commit details
  15. Copy the full SHA
    3d60c78 View commit details
  16. Simpler API.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    76cba8c View commit details
  17. Checks.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    4c846de View commit details
  18. Typos.

    pleroy committed Aug 14, 2021
    Copy the full SHA
    c26371c View commit details

Commits on Aug 15, 2021

  1. Copy the full SHA
    62c03c9 View commit details
  2. Merge pull request #3094 from pleroy/DownsamplingMaster

    Change the Downsampling class to manage a proper data structure and its invariants
    pleroy authored Aug 15, 2021
    Copy the full SHA
    e5b193e View commit details
Showing with 166 additions and 165 deletions.
  1. +29 −34 physics/discrete_trajectory.hpp
  2. +127 −125 physics/discrete_trajectory_body.hpp
  3. +3 −3 physics/ephemeris_test.cpp
  4. +2 −1 physics/forkable_body.hpp
  5. +5 −2 serialization/physics.proto
63 changes: 29 additions & 34 deletions physics/discrete_trajectory.hpp
Original file line number Diff line number Diff line change
@@ -198,56 +198,47 @@ class DiscreteTrajectory : public Forkable<DiscreteTrajectory<Frame>,
private:
using Timeline = typename DiscreteTrajectoryTraits<Frame>::Timeline;

// A helper class to manage a dense timeline.
class Downsampling {
public:
Downsampling(std::int64_t max_dense_intervals,
Length tolerance,
TimelineConstIterator start_of_dense_timeline,
Timeline const& timeline);

TimelineConstIterator start_of_dense_timeline() const;
// |start_of_dense_timeline()->first|, for readability.
Instant const& first_dense_time() const;
// Keeps |dense_intervals_| consistent with the new
// |start_of_dense_timeline_|.
void SetStartOfDenseTimeline(TimelineConstIterator value,
Timeline const& timeline);

// Sets |dense_intervals_| to
// |std::distance(start_of_dense_timeline_, timeline.end()) - 1|. This is
// linear in the value of |dense_intervals_|.
void RecountDenseIntervals(Timeline const& timeline);
// Increments |dense_intervals_|. The caller must ensure that this is
// equivalent to |RecountDenseIntervals(timeline)|. This is checked in
// debug mode.
void increment_dense_intervals(Timeline const& timeline);
Length tolerance);

// Construction parameters.
std::int64_t max_dense_intervals() const;
bool reached_max_dense_intervals() const;

Length tolerance() const;

// Appends a point to the dense timeline.
void Append(TimelineConstIterator it);

// Forgets the points of the dense timeline after/before t. The semantics
// are the same as that of the corresponding functions of
// DiscreteTrajectory.
void ForgetAfter(Instant const& t);
void ForgetBefore(Instant const& t);

bool empty() const;
bool full() const;

// Returns the |dense_iterators_|, giving ownership to the caller.
std::vector<TimelineConstIterator> dense_iterators();

void WriteToMessage(
not_null<serialization::DiscreteTrajectory::Downsampling*> message,
Timeline const& timeline) const;
not_null<serialization::DiscreteTrajectory::Downsampling*> message)
const;
static Downsampling ReadFromMessage(
serialization::DiscreteTrajectory::Downsampling const& message,
Timeline const& timeline);

private:
// The maximal value that |dense_intervals| is allowed to reach before
// downsampling occurs.
// The maximal number of dense intervals before downsampling occurs.
std::int64_t const max_dense_intervals_;
// The tolerance for downsampling with |FitHermiteSpline|.
Length const tolerance_;
// An iterator to the first point of the timeline which is not the left
// endpoint of a downsampled interval. Not |timeline_.end()| if the
// timeline is nonempty.
TimelineConstIterator start_of_dense_timeline_;
// |std::distance(start_of_dense_timeline, timeline_.cend()) - 1|. Kept as
// an optimization for |Append| as it can be maintained by incrementing,
// whereas |std::distance| is linear in the value of the result.
std::int64_t dense_intervals_;

// TODO(phl): Note that, with forks, the iterators in this vector may belong
// to different maps.
std::vector<TimelineConstIterator> dense_iterators_;
};

// This trajectory need not be a root.
@@ -264,6 +255,10 @@ class DiscreteTrajectory : public Forkable<DiscreteTrajectory<Frame>,
Hermite3<Instant, Position<Frame>> GetInterpolation(
Iterator const& upper) const;

// Updates the downsampling object to reflect that a point was appended to
// this trajectory.
absl::Status UpdateDownsampling(TimelineConstIterator const appended);

Timeline timeline_;

std::optional<Downsampling> downsampling_;
Loading