Skip to content

Commit

Permalink
Merge pull request #2780 from pleroy/2535
Browse files Browse the repository at this point in the history
Remove rotation traces related to #2519
  • Loading branch information
pleroy authored Nov 7, 2020
2 parents 59e6ae5 + b79d801 commit 517a386
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 124 deletions.
20 changes: 0 additions & 20 deletions ksp_plugin/interface_vessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,5 @@ XYZ __cdecl principia__VesselVelocity(Plugin const* const plugin,
return m.Return(ToXYZ(plugin->VesselVelocity(vessel_guid)));
}

void __cdecl principia__SetAngularMomentumConservation(
bool const conserve_angular_momentum) {
journal::Method<journal::SetAngularMomentumConservation> m(
{conserve_angular_momentum});
ksp_plugin::PileUp::conserve_angular_momentum = conserve_angular_momentum;
return m.Return();
}

char const* __cdecl principia__VesselGetPileUpTrace(
Plugin const* const plugin,
char const* const vessel_guid) {
journal::Method<journal::VesselGetPileUpTrace> m({plugin, vessel_guid});
CHECK_NOTNULL(plugin);
char const* trace;
plugin->GetVessel(vessel_guid)->ForSomePart([&trace](ksp_plugin::Part& part) {
trace = part.containing_pile_up()->trace.data();
});
return m.Return(trace);
}

} // namespace interface
} // namespace principia
43 changes: 1 addition & 42 deletions ksp_plugin/pile_up.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,7 @@ void PileUp::DeformPileUpIfNeeded(Instant const& t) {
t, {NonRotatingPileUp::origin, NonRotatingPileUp::unmoving});

RigidMotion<ApparentPileUp, NonRotatingPileUp> const rotational_correction =
conserve_angular_momentum
? actual_pile_up_motion * apparent_pile_up_motion.Inverse()
: RigidMotion<ApparentPileUp, NonRotatingPileUp>::Identity();
actual_pile_up_motion * apparent_pile_up_motion.Inverse();
RigidMotion<Apparent, NonRotatingPileUp> const correction =
rotational_correction * apparent_system.LinearMotion().Inverse();

Expand All @@ -531,43 +529,6 @@ void PileUp::DeformPileUpIfNeeded(Instant const& t) {
actual_rigid_motion.rigid_transformation());
}
apparent_part_rigid_motion_.clear();

#if 0
std::stringstream s;
Angle const α =
rotational_correction.orthogonal_map().AsRotation().RotationAngle();
AngularVelocity<PileUpPrincipalAxes> const ω_apparent =
apparent_pile_up_motion.angular_velocity_of_to_frame();
AngularVelocity<PileUpPrincipalAxes> const ω_actual =
actual_pile_up_motion.angular_velocity_of_to_frame();
constexpr AngularFrequency rpm = 2 * π * Radian / quantities::si::Minute;
s << "|Lap|: " << apparent_angular_momentum.Norm() << "\n"
<< "|Lac|: " << angular_momentum_.Norm() << "\n"
<< "|Lap-Lac|: "
<< (angular_momentum_ - Identity<ApparentPileUp, NonRotatingPileUp>()(
apparent_angular_momentum))
.Norm()
<< "\n"
<< "|Lap|-|Lac|: "
<< angular_momentum_.Norm() - apparent_angular_momentum.Norm() << "\n"
<< u8"∡Lap, Lac: "
<< geometry::AngleBetween(angular_momentum_,
Identity<ApparentPileUp, NonRotatingPileUp>()(
apparent_angular_momentum)) /
quantities::si::Degree
<< u8"°\n"
<< u8"α: " << α / quantities::si::Degree << u8"°\n"
<< u8"|ωap|: " << ω_apparent.Norm() / rpm << " rpm\n"
<< u8"|ωac|: " << ω_actual.Norm() / rpm << " rpm\n"
<< u8"|ωac|-|ωap|: " << (ω_actual.Norm() - ω_apparent.Norm()) / rpm
<< " rpm\n"
<< u8"∡ωac, ωap: "
<< geometry::AngleBetween(ω_actual, ω_apparent) / quantities::si::Degree
<< u8"°\n"
<< "reference part: " << reference_part->ShortDebugString() << "\n"
<< u8"|ωref|: " << reference_part_proper_ω / rpm << " rpm\n";
trace = s.str();
#endif
}

Status PileUp::AdvanceTime(Instant const& t) {
Expand Down Expand Up @@ -692,8 +653,6 @@ PileUpFuture::PileUpFuture(not_null<PileUp const*> const pile_up,
: pile_up(pile_up),
future(std::move(future)) {}

bool PileUp::conserve_angular_momentum = true;

} // namespace internal_pile_up
} // namespace ksp_plugin
} // namespace principia
3 changes: 0 additions & 3 deletions ksp_plugin/pile_up.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ class PileUp {

virtual ~PileUp();

std::string trace;
static bool conserve_angular_momentum;

// This class is moveable.
PileUp(PileUp&& pile_up) = default;
PileUp& operator=(PileUp&& pile_up) = default;
Expand Down
33 changes: 0 additions & 33 deletions ksp_plugin_adapter/main_window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,33 +238,6 @@ protected override void RenderWindow(int window_id) {
}

private void RenderKSPFeatures() {
if (show_2519_debugging_ui) {
string offsets = "";
if (FlightGlobals.ActiveVessel != null) {
foreach (var part in FlightGlobals.ActiveVessel.parts) {
double? offset = part.rb?.centerOfMass.magnitude;
if (offset != 0) {
offsets += $"{part.name}: {offset:F3} m; ";
}
}
}
UnityEngine.GUILayout.TextArea(
offsets,
style: Style.Multiline(UnityEngine.GUI.skin.textArea));
conserve_angular_momentum = UnityEngine.GUILayout.Toggle(
conserve_angular_momentum,
"Conserve angular momentum");
Interface.SetAngularMomentumConservation(conserve_angular_momentum);
string trace = null;
if (FlightGlobals.ActiveVessel != null &&
plugin.HasVessel(FlightGlobals.ActiveVessel.id.ToString())) {
trace = plugin.VesselGetPileUpTrace(
FlightGlobals.ActiveVessel.id.ToString());
}
UnityEngine.GUILayout.TextArea(
trace ?? "No managed active vessel",
style : Style.Multiline(UnityEngine.GUI.skin.textArea));
}
display_patched_conics = UnityEngine.GUILayout.Toggle(
value : display_patched_conics,
text : "Display patched conics (do not use for flight planning!)");
Expand Down Expand Up @@ -517,12 +490,6 @@ private void RenderToggleableSection(string name,
value = 7 * 24 * 60 * 60
};

// These flags exist to facilitate investigation of #2519.
// They must not be serialized: their non-default values can lead to absurd
// behaviour.
private static bool conserve_angular_momentum = true;
private static readonly bool show_2519_debugging_ui = false;

private static readonly double[] prediction_length_tolerances_ =
{1e-3, 1e-2, 1e0, 1e1, 1e2, 1e3, 1e4};
private static readonly long[] prediction_steps_ =
Expand Down
26 changes: 0 additions & 26 deletions serialization/journal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -218,32 +218,6 @@ message Method {
extensions 5000 to 5999; // Last used: 5174.
}

message SetAngularMomentumConservation {
extend Method {
optional SetAngularMomentumConservation extension = 5999;
}
message In {
required bool conserve_angular_momentum = 1;
}
optional In in = 1;
}

message VesselGetPileUpTrace {
extend Method {
optional VesselGetPileUpTrace extension = 5998;
}
message In {
required fixed64 plugin = 1 [(pointer_to) = "Plugin const",
(is_subject) = true];
required string vessel_guid = 2;
}
message Return {
required string result = 1;
}
optional In in = 1;
optional Return return = 3;
}

message AdvanceTime {
extend Method {
optional AdvanceTime extension = 5019;
Expand Down

0 comments on commit 517a386

Please sign in to comment.