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

Commits on Mar 9, 2017

  1. Copy the full SHA
    c2517c1 View commit details

Commits on Mar 10, 2017

  1. Physics compiles.

    pleroy committed Mar 10, 2017
    Copy the full SHA
    b70540c View commit details
  2. Geometry compiles.

    pleroy committed Mar 10, 2017
    Copy the full SHA
    7fa9c74 View commit details
  3. Plugin compiling.

    pleroy committed Mar 10, 2017
    Copy the full SHA
    b3f369d View commit details
  4. Copy the full SHA
    aaa392b View commit details
  5. Physics test passing.

    pleroy committed Mar 10, 2017
    Copy the full SHA
    145fc8d View commit details
  6. Required.

    pleroy committed Mar 10, 2017
    Copy the full SHA
    4e513a5 View commit details

Commits on Mar 11, 2017

  1. Copy the full SHA
    07b3527 View commit details
  2. After egg's review.

    pleroy committed Mar 11, 2017
    Copy the full SHA
    5adc6e8 View commit details
  3. BOM

    pleroy committed Mar 11, 2017
    Copy the full SHA
    6bbb137 View commit details
  4. Merge pull request #1241 from pleroy/NoCompatibility

    Remove compatibility code
    pleroy authored Mar 11, 2017
    Copy the full SHA
    ecc844e View commit details
62 changes: 3 additions & 59 deletions geometry/grassmann_body.hpp
Original file line number Diff line number Diff line change
@@ -16,44 +16,6 @@ namespace internal_grassmann {
using base::not_constructible;
using quantities::ArcTan;

// This struct helps in reading coordinates in compatilibity mode. We used to
// use a left-handed OLD_BARYCENTRIC frame, and switched to use a right-handed
// BARYCENTRIC frame in Borel. As a consequence, reading old serialized data
// results in a frame tag mismatch and must flip the multivectors.
template<typename Multivector,
typename Frame,
typename Tag = typename Frame::Tag>
struct CompatibilityHelper : not_constructible {
static bool MustFlip(serialization::Frame const& frame);
};

template<typename Multivector, typename Frame>
struct CompatibilityHelper<Multivector, Frame, serialization::Frame::PluginTag>
: not_constructible {
CompatibilityHelper() = delete;

static bool MustFlip(serialization::Frame const& frame);
};

template<typename Multivector, typename Frame, typename Tag>
bool CompatibilityHelper<Multivector, Frame, Tag>::MustFlip(
serialization::Frame const& frame) {
Frame::ReadFromMessage(frame);
return false;
}

template<typename Multivector, typename Frame>
bool CompatibilityHelper<Multivector, Frame, serialization::Frame::PluginTag>::
MustFlip(serialization::Frame const& frame) {
if (frame.tag() == serialization::Frame::PRE_BOREL_BARYCENTRIC &&
Frame::tag == serialization::Frame::BARYCENTRIC) {
return true;
} else {
Frame::ReadFromMessage(frame);
return false;
}
}

template<typename Scalar, typename Frame>
Multivector<Scalar, Frame, 1>::Multivector() {}

@@ -149,39 +111,21 @@ template<typename Scalar, typename Frame>
Multivector<Scalar, Frame, 1> Multivector<Scalar, Frame, 1>::ReadFromMessage(
serialization::Multivector const& message) {
CHECK(message.has_vector());
auto multivector =
Multivector(R3Element<Scalar>::ReadFromMessage(message.vector()));
if (CompatibilityHelper<Multivector, Frame>::MustFlip(message.frame())) {
multivector =
Permutation<Frame, Frame>(Permutation<Frame, Frame>::XZY)(multivector);
}
return multivector;
return Multivector(R3Element<Scalar>::ReadFromMessage(message.vector()));
}

template<typename Scalar, typename Frame>
Multivector<Scalar, Frame, 2> Multivector<Scalar, Frame, 2>::ReadFromMessage(
serialization::Multivector const& message) {
CHECK(message.has_bivector());
auto multivector =
Multivector(R3Element<Scalar>::ReadFromMessage(message.bivector()));
if (CompatibilityHelper<Multivector, Frame>::MustFlip(message.frame())) {
multivector =
Permutation<Frame, Frame>(Permutation<Frame, Frame>::XZY)(multivector);
}
return multivector;
return Multivector(R3Element<Scalar>::ReadFromMessage(message.bivector()));
}

template<typename Scalar, typename Frame>
Multivector<Scalar, Frame, 3> Multivector<Scalar, Frame, 3>::ReadFromMessage(
serialization::Multivector const& message) {
CHECK(message.has_trivector());
auto multivector =
Multivector(Scalar::ReadFromMessage(message.trivector()));
if (CompatibilityHelper<Multivector, Frame>::MustFlip(message.frame())) {
multivector =
Permutation<Frame, Frame>(Permutation<Frame, Frame>::XZY)(multivector);
}
return multivector;
return Multivector(Scalar::ReadFromMessage(message.trivector()));
}

template<typename LScalar, typename RScalar, typename Frame>
5 changes: 2 additions & 3 deletions geometry/permutation_test.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

#include "geometry/permutation.hpp"

#include <vector>

#include "geometry/frame.hpp"
#include "geometry/identity.hpp"
#include "geometry/orthogonal_map.hpp"
// TODO(egg): this should be at the top, but there's a circular dependency due
// to compatibility test.
#include "geometry/permutation.hpp"
#include "geometry/r3_element.hpp"
#include "glog/logging.h"
#include "gmock/gmock.h"
6 changes: 2 additions & 4 deletions ksp_plugin/manœuvre_body.hpp
Original file line number Diff line number Diff line change
@@ -203,15 +203,13 @@ template<typename InertialFrame, typename Frame>
Manœuvre<InertialFrame, Frame> Manœuvre<InertialFrame, Frame>::ReadFromMessage(
serialization::Manoeuvre const& message,
not_null<Ephemeris<InertialFrame>*> const ephemeris) {
// |check_not_null| is fine below because we don't have to worry about pre-
// Brouwer compatibility for this class.
Manœuvre manœuvre(
Force::ReadFromMessage(message.thrust()),
Mass::ReadFromMessage(message.initial_mass()),
SpecificImpulse::ReadFromMessage(message.specific_impulse()),
Vector<double, Frenet<Frame>>::ReadFromMessage(message.direction()),
check_not_null(DynamicFrame<InertialFrame, Frame>::ReadFromMessage(
ephemeris, message.frame())));
DynamicFrame<InertialFrame, Frame>::ReadFromMessage(
ephemeris, message.frame()));
manœuvre.set_duration(Time::ReadFromMessage(message.duration()));
manœuvre.set_initial_time(Instant::ReadFromMessage(message.initial_time()));
return manœuvre;
110 changes: 30 additions & 80 deletions ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -1011,10 +1011,6 @@ Instant Plugin::GameEpoch() const {
return game_epoch_;
}

bool Plugin::MustRotateBodies() const {
return !is_pre_cardano_;
}

Instant Plugin::CurrentTime() const {
return current_time_;
}
@@ -1062,11 +1058,7 @@ void Plugin::WriteToMessage(
message->mutable_prediction_parameters());

planetarium_rotation_.WriteToMessage(message->mutable_planetarium_rotation());
if (!is_pre_cardano_) {
// A pre-Cardano save stays pre-Cardano; we cannot pull rotational
// properties out of thin air.
game_epoch_.WriteToMessage(message->mutable_game_epoch());
}
game_epoch_.WriteToMessage(message->mutable_game_epoch());
current_time_.WriteToMessage(message->mutable_current_time());
Index const sun_index = FindOrDie(celestial_to_index, sun_);
message->set_sun_index(sun_index);
@@ -1078,22 +1070,11 @@ void Plugin::WriteToMessage(
not_null<std::unique_ptr<Plugin>> Plugin::ReadFromMessage(
serialization::Plugin const& message) {
LOG(INFO) << __FUNCTION__;
bool const is_pre_bourbaki = message.pre_bourbaki_celestial_size() > 0;
std::unique_ptr<Ephemeris<Barycentric>> ephemeris;
IndexToOwnedCelestial celestials;
std::unique_ptr<Ephemeris<Barycentric>> ephemeris =
Ephemeris<Barycentric>::ReadFromMessage(message.ephemeris());

if (is_pre_bourbaki) {
ephemeris = Ephemeris<Barycentric>::ReadFromPreBourbakiMessages(
message.pre_bourbaki_celestial(),
fitting_tolerance,
DefaultEphemerisParameters());
ReadCelestialsFromMessages(*ephemeris,
message.pre_bourbaki_celestial(),
celestials);
} else {
ephemeris = Ephemeris<Barycentric>::ReadFromMessage(message.ephemeris());
ReadCelestialsFromMessages(*ephemeris, message.celestial(), celestials);
}
IndexToOwnedCelestial celestials;
ReadCelestialsFromMessages(*ephemeris, message.celestial(), celestials);

GUIDToOwnedVessel vessels;
for (auto const& vessel_message : message.vessel()) {
@@ -1112,29 +1093,17 @@ not_null<std::unique_ptr<Plugin>> Plugin::ReadFromMessage(

Instant const current_time = Instant::ReadFromMessage(message.current_time());

bool const is_pre_буняковский = !(message.has_history_parameters() &&
message.has_prolongation_parameters() &&
message.has_prediction_parameters());
auto const history_parameters =
is_pre_буняковский
? DefaultHistoryParameters()
: Ephemeris<Barycentric>::FixedStepParameters::ReadFromMessage(
message.history_parameters());
Ephemeris<Barycentric>::FixedStepParameters::ReadFromMessage(
message.history_parameters());
auto const prolongation_parameters =
is_pre_буняковский
? DefaultProlongationParameters()
: Ephemeris<Barycentric>::AdaptiveStepParameters::ReadFromMessage(
message.prolongation_parameters());
Ephemeris<Barycentric>::AdaptiveStepParameters::ReadFromMessage(
message.prolongation_parameters());
auto const prediction_parameters =
is_pre_буняковский
? DefaultPredictionParameters()
: Ephemeris<Barycentric>::AdaptiveStepParameters::ReadFromMessage(
message.prediction_parameters());
Ephemeris<Barycentric>::AdaptiveStepParameters::ReadFromMessage(
message.prediction_parameters());

bool const is_pre_cardano = !message.has_game_epoch();
Instant const game_epoch =
is_pre_cardano ? astronomy::J2000
: Instant::ReadFromMessage(message.game_epoch());
Instant const game_epoch = Instant::ReadFromMessage(message.game_epoch());

// Can't use |make_unique| here without implementation-dependent friendships.
auto plugin = std::unique_ptr<Plugin>(
@@ -1147,19 +1116,11 @@ not_null<std::unique_ptr<Plugin>> Plugin::ReadFromMessage(
Angle::ReadFromMessage(message.planetarium_rotation()),
game_epoch,
current_time,
message.sun_index(),
is_pre_cardano));
message.sun_index()));
std::unique_ptr<NavigationFrame> plotting_frame =
NavigationFrame::ReadFromMessage(plugin->ephemeris_.get(),
message.plotting_frame());
if (plotting_frame == nullptr) {
// In the pre-Brouwer compatibility case you get a plotting frame centred on
// the Sun.
plugin->SetPlottingFrame(
plugin->NewBodyCentredNonRotatingNavigationFrame(message.sun_index()));
} else {
plugin->SetPlottingFrame(std::move(plotting_frame));
}
message.plotting_frame());
plugin->SetPlottingFrame(std::move(plotting_frame));
return std::move(plugin);
}

@@ -1187,8 +1148,7 @@ Plugin::Plugin(
Angle const& planetarium_rotation,
Instant const& game_epoch,
Instant const& current_time,
Index const sun_index,
bool const is_pre_cardano)
Index const sun_index)
: vessels_(std::move(vessels)),
celestials_(std::move(celestials)),
ephemeris_(std::move(ephemeris)),
@@ -1198,16 +1158,13 @@ Plugin::Plugin(
planetarium_rotation_(planetarium_rotation),
game_epoch_(game_epoch),
current_time_(current_time),
sun_(FindOrDie(celestials_, sun_index).get()),
is_pre_cardano_(is_pre_cardano) {
sun_(FindOrDie(celestials_, sun_index).get()) {
for (auto const& pair : vessels_) {
auto const& vessel = pair.second;
kept_vessels_.emplace(vessel.get());
}
if (!is_pre_cardano_) {
main_body_ = CHECK_NOTNULL(
dynamic_cast_not_null<RotatingBody<Barycentric> const*>(sun_->body()));
}
main_body_ = CHECK_NOTNULL(
dynamic_cast_not_null<RotatingBody<Barycentric> const*>(sun_->body()));
initializing_.Flop();
}

@@ -1262,24 +1219,17 @@ Rotation<Barycentric, AliceSun> Plugin::PlanetariumRotation() const {
// http://astropedia.astrogeology.usgs.gov/download/Docs/WGCCRE/WGCCRE2009reprint.pdf.
struct PlanetariumFrame;

if (is_pre_cardano_) {
return Rotation<Barycentric, AliceSun>(
planetarium_rotation_,
Bivector<double, Barycentric>({0, 0, 1}),
DefinesFrame<AliceSun>{});
} else {
CHECK_NOTNULL(main_body_);
Rotation<Barycentric, PlanetariumFrame> const to_planetarium(
π / 2 * Radian + main_body_->right_ascension_of_pole(),
π / 2 * Radian - main_body_->declination_of_pole(),
0 * Radian,
EulerAngles::ZXZ,
DefinesFrame<PlanetariumFrame>{});
return Rotation<PlanetariumFrame, AliceSun>(
planetarium_rotation_,
Bivector<double, PlanetariumFrame>({0, 0, 1}),
DefinesFrame<AliceSun>{}) * to_planetarium;
}
CHECK_NOTNULL(main_body_);
Rotation<Barycentric, PlanetariumFrame> const to_planetarium(
π / 2 * Radian + main_body_->right_ascension_of_pole(),
π / 2 * Radian - main_body_->declination_of_pole(),
0 * Radian,
EulerAngles::ZXZ,
DefinesFrame<PlanetariumFrame>{});
return Rotation<PlanetariumFrame, AliceSun>(
planetarium_rotation_,
Bivector<double, PlanetariumFrame>({0, 0, 1}),
DefinesFrame<AliceSun>{}) * to_planetarium;
}

Vector<double, World> Plugin::FromVesselFrenetFrame(
9 changes: 2 additions & 7 deletions ksp_plugin/plugin.hpp
Original file line number Diff line number Diff line change
@@ -352,7 +352,6 @@ class Plugin {
virtual OrthogonalMap<World, Barycentric> WorldToBarycentric() const;

virtual Instant GameEpoch() const;
virtual bool MustRotateBodies() const;

virtual Instant CurrentTime() const;

@@ -396,8 +395,7 @@ class Plugin {
Angle const& planetarium_rotation,
Instant const& game_epoch,
Instant const& current_time,
Index sun_index,
bool is_pre_cardano);
Index sun_index);

// We virtualize this function for testing purposes.
// Requires |absolute_initialization_| and consumes it.
@@ -419,7 +417,7 @@ class Plugin {
Vector<double, Frenet<Navigation>> const& vector) const;

// Fill |celestials| using the |index| and |parent_index| fields found in
// |celestial_messages| (which may be pre- or post-Bourbaki).
// |celestial_messages|.
template<typename T>
static void ReadCelestialsFromMessages(
Ephemeris<Barycentric> const& ephemeris,
@@ -515,9 +513,6 @@ class Plugin {
std::set<not_null<Vessel*>> new_unloaded_vessels_;
std::experimental::optional<DegreesOfFreedom<Barycentric>> bubble_barycentre_;

// Compatibility.
bool is_pre_cardano_ = false;

friend class NavballFrameField;
friend class TestablePlugin;
};
36 changes: 0 additions & 36 deletions ksp_plugin_test/borel.proto.hex

This file was deleted.

45 changes: 0 additions & 45 deletions ksp_plugin_test/brouwer.proto.hex

This file was deleted.

4 changes: 0 additions & 4 deletions ksp_plugin_test/ksp_plugin_test.vcxproj
Original file line number Diff line number Diff line change
@@ -59,10 +59,6 @@
<Project>{5c482c18-bbae-484d-a211-a25c86370061}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="borel.proto.hex" />
<None Include="brouwer.proto.hex" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mock_flight_plan.hpp" />
<ClInclude Include="mock_manœuvre.hpp" />
8 changes: 0 additions & 8 deletions ksp_plugin_test/ksp_plugin_test.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -112,12 +112,4 @@
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="brouwer.proto.hex">
<Filter>Resource Files</Filter>
</None>
<None Include="borel.proto.hex">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>
Loading