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

Commits on Jul 6, 2021

  1. JustAfter & JustBefore

    eggrobin committed Jul 6, 2021
    Copy the full SHA
    b640281 View commit details
  2. Copy the full SHA
    fefb234 View commit details
  3. Copy the full SHA
    9ce778f View commit details
  4. Merge pull request #3050 from eggrobin/next_time

    JustAfter & JustBefore
    eggrobin authored Jul 6, 2021
    Copy the full SHA
    88817a7 View commit details
Showing with 38 additions and 0 deletions.
  1. +9 −0 geometry/named_quantities.hpp
  2. +14 −0 geometry/point.hpp
  3. +15 −0 geometry/point_body.hpp
9 changes: 9 additions & 0 deletions geometry/named_quantities.hpp
Original file line number Diff line number Diff line change
@@ -34,5 +34,14 @@ template<typename Frame>
using InertiaTensor =
SymmetricBilinearForm<quantities::MomentOfInertia, Frame, Bivector>;

// IEEE 754:2008 nextUp and nextDown for Instants.
// We would like to avoid the terms “up” and “down” when referring to the
// passage of time. We avoid the term “next” in one direction because of the
// confusability with |std::nextafter|, which has different semantics, and in
// the other because of the awkwardness of the phrase “next before”.
// Defined inline for want of a way to alias functions in C++.
constexpr Instant JustAfter(Instant const t) { return NextUp(t); }
constexpr Instant JustBefore(Instant const t) { return NextDown(t); }

} // namespace geometry
} // namespace principia
14 changes: 14 additions & 0 deletions geometry/point.hpp
Original file line number Diff line number Diff line change
@@ -85,6 +85,13 @@ class Point final {
friend constexpr typename std::enable_if_t<is_quantity_v<V>, bool>
operator>(Point<V> const& left, Point<V> const& right);

template<typename V>
friend constexpr typename std::enable_if_t<is_quantity_v<V>, Point<V>>
NextUp(Point<V> x);
template<typename V>
friend constexpr typename std::enable_if_t<is_quantity_v<V>, Point<V>>
NextDown(Point<V> x);

template<typename V>
friend std::string DebugString(Point<V> const& point);

@@ -121,6 +128,13 @@ template<typename Vector>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool>
operator>(Point<Vector> const& left, Point<Vector> const& right);

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, Point<Vector>>
NextUp(Point<Vector> x);
template<typename Vector>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, Point<Vector>>
NextDown(Point<Vector> x);

template<typename Vector>
std::string DebugString(Point<Vector> const& point);

15 changes: 15 additions & 0 deletions geometry/point_body.hpp
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
#include "base/not_constructible.hpp"
#include "geometry/grassmann.hpp"
#include "glog/logging.h"
#include "quantities/elementary_functions.hpp"
#include "quantities/quantities.hpp"

namespace principia {
@@ -18,6 +19,8 @@ namespace internal_point {
using base::not_constructible;
using quantities::FusedMultiplyAdd;
using quantities::FusedNegatedMultiplyAdd;
using quantities::NextDown;
using quantities::NextUp;
using quantities::Product;
using quantities::Quantity;

@@ -168,6 +171,18 @@ constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool> operator>(
return left.coordinates_ > right.coordinates_;
}

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, Point<Vector>>
NextUp(Point<Vector> const x) {
return Point<Vector>(NextUp(x.coordinates_));
}

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, Point<Vector>>
NextDown(Point<Vector> const x) {
return Point<Vector>(NextDown(x.coordinates_));
}

template<typename Vector>
std::string DebugString(Point<Vector> const& point) {
using quantities::DebugString;