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

Commits on May 15, 2019

  1. always show nodes

    eggrobin committed May 15, 2019
    Copy the full SHA
    b8e5a92 View commit details
  2. Copy the full SHA
    f625bd8 View commit details
  3. refactor a bit

    eggrobin committed May 15, 2019
    Copy the full SHA
    4a474a3 View commit details
  4. postmodern C#

    eggrobin committed May 15, 2019
    Copy the full SHA
    e15f731 View commit details

Commits on May 16, 2019

  1. Copy the full SHA
    ccb3374 View commit details
  2. using

    eggrobin committed May 16, 2019
    Copy the full SHA
    ce66565 View commit details
  3. bikeshedding

    eggrobin committed May 16, 2019
    Copy the full SHA
    ebbabe2 View commit details

Commits on May 18, 2019

  1. merge

    eggrobin committed May 18, 2019
    Copy the full SHA
    147e50e View commit details
  2. Copy the full SHA
    0b61a38 View commit details

Commits on May 19, 2019

  1. compute nodes with filtering

    eggrobin committed May 19, 2019
    Copy the full SHA
    7ec9cb0 View commit details
  2. threshold

    eggrobin committed May 19, 2019
    Copy the full SHA
    dd47541 View commit details
  3. test

    eggrobin committed May 19, 2019
    Copy the full SHA
    52834d0 View commit details
  4. base

    eggrobin committed May 19, 2019
    Copy the full SHA
    1c12601 View commit details
  5. Copy the full SHA
    cf14adf View commit details
  6. add the file

    eggrobin committed May 19, 2019
    Copy the full SHA
    6f21118 View commit details
  7. lint and warning

    eggrobin committed May 19, 2019
    Copy the full SHA
    b3acbb1 View commit details
  8. after pleroy's review

    eggrobin committed May 19, 2019
    Copy the full SHA
    c5ec986 View commit details
  9. Merge pull request #2170 from eggrobin/equator

    Show nodes with respect to the equator
    eggrobin authored May 19, 2019
    Copy the full SHA
    8d7cc4b View commit details
1 change: 1 addition & 0 deletions base/base.vcxproj
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
<ClInclude Include="base64.hpp" />
<ClInclude Include="base64_body.hpp" />
<ClInclude Include="bundle.hpp" />
<ClInclude Include="constant_function.hpp" />
<ClInclude Include="disjoint_sets.hpp" />
<ClInclude Include="disjoint_sets_body.hpp" />
<ClInclude Include="encoder.hpp" />
3 changes: 3 additions & 0 deletions base/base.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -170,6 +170,9 @@
<ClInclude Include="graveyard_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="constant_function.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="not_null_test.cpp">
24 changes: 24 additions & 0 deletions base/constant_function.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

namespace principia {
namespace base {

// A function object that can be called with arbitrary arguments, and always
// returns the same |value|.
template<typename T>
struct ConstantFunction {
template<typename... Args>
constexpr T operator()(Args&&...) {
return value;
}

T value;
};

template <typename T>
constexpr ConstantFunction<T> Identically(T value) {
return {value};
}

} // namespace base
} // namespace principia
37 changes: 37 additions & 0 deletions ksp_plugin/equator_relevance_threshold.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "ksp_plugin/equator_relevance_threshold.hpp"

#include <algorithm>

#include "physics/geopotential.hpp"
#include "physics/oblate_body.hpp"
#include "quantities/elementary_functions.hpp"

namespace principia {
namespace ksp_plugin {
namespace internal_equator_relevance_threshold {

using physics::Geopotential;
using physics::OblateBody;
using quantities::Cbrt;
using quantities::Pow;
using quantities::si::Metre;
using quantities::si::Radian;

Length EquatorRelevanceThreshold(RotatingBody<Barycentric> const& body) {
OblateBody<Barycentric> const* oblate_body =
dynamic_cast<OblateBody<Barycentric> const*>(&body);
Length const j2_threshold =
oblate_body == nullptr
? 0 * Metre
: Geopotential<Barycentric>(
oblate_body,
/*tolerance=*/0x1p-24).degree_damping()[2].inner_threshold();
Length const supersynchronous_threshold =
Cbrt(body.gravitational_parameter() /
Pow<2>(body.angular_frequency() / (2 * Radian)));
return std::max(j2_threshold, supersynchronous_threshold);
}

} // namespace internal_equator_relevance_threshold
} // namespace ksp_plugin
} // namespace principia
27 changes: 27 additions & 0 deletions ksp_plugin/equator_relevance_threshold.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "ksp_plugin/frames.hpp"
#include "physics/rotating_body.hpp"
#include "quantities/named_quantities.hpp"

namespace principia {
namespace ksp_plugin {
namespace internal_equator_relevance_threshold {

using quantities::Length;
using physics::RotatingBody;

// Returns a distance from |body| that we consider is too far for the equator to
// be of interest. Specifically, this distance is the maximum of
// - the semimajor axis of a supersynchronous orbit (1 orbit for 2 body
// revolutions);
// - the distance at which a |Geopotential| with a tolerance of 0x1p-24 starts
// damping dynamical oblateness;
Length EquatorRelevanceThreshold(RotatingBody<Barycentric> const& body);

} // namespace internal_equator_relevance_threshold

using internal_equator_relevance_threshold::EquatorRelevanceThreshold;

} // namespace ksp_plugin
} // namespace principia
2 changes: 2 additions & 0 deletions ksp_plugin/ksp_plugin.vcxproj
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
<Import Project="$(SolutionDir)principia.props" />
<ItemGroup>
<ClInclude Include="celestial.hpp" />
<ClInclude Include="equator_relevance_threshold.hpp" />
<ClInclude Include="identification.hpp" />
<ClInclude Include="integrators.hpp" />
<ClInclude Include="iterators.hpp" />
@@ -41,6 +42,7 @@
<ClCompile Include="..\journal\recorder.cpp" />
<ClCompile Include="..\numerics\cbrt.cpp" />
<ClCompile Include="celestial.cpp" />
<ClCompile Include="equator_relevance_threshold.cpp" />
<ClCompile Include="flight_plan.cpp" />
<ClCompile Include="identification.cpp" />
<ClCompile Include="integrators.cpp" />
6 changes: 6 additions & 0 deletions ksp_plugin/ksp_plugin.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -68,6 +68,9 @@
<ClInclude Include="iterators_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="equator_relevance_threshold.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="interface.cpp">
@@ -151,6 +154,9 @@
<ClCompile Include="..\numerics\cbrt.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="equator_relevance_threshold.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\serialization\journal.proto" />
31 changes: 26 additions & 5 deletions ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@
#include <list>
#include <map>
#include <optional>
#include <set>
#include <string>
#include <thread>
#include <utility>
#include <vector>
#include <set>

#include "astronomy/epoch.hpp"
#include "astronomy/solar_system_fingerprints.hpp"
@@ -35,6 +35,7 @@
#include "geometry/permutation.hpp"
#include "glog/logging.h"
#include "glog/stl_logging.h"
#include "ksp_plugin/equator_relevance_threshold.hpp"
#include "ksp_plugin/integrators.hpp"
#include "ksp_plugin/part_subsets.hpp"
#include "physics/apsides.hpp"
@@ -54,9 +55,9 @@ namespace principia {
namespace ksp_plugin {
namespace internal_plugin {

using astronomy::ParseTT;
using astronomy::KSPStockSystemFingerprint;
using astronomy::KSPStabilizedSystemFingerprint;
using astronomy::KSPStockSystemFingerprint;
using astronomy::ParseTT;
using astronomy::StabilizeKSP;
using base::check_not_null;
using base::dynamic_cast_not_null;
@@ -65,8 +66,8 @@ using base::FindOrDie;
using base::Fingerprint2011;
using base::HexadecimalEncoder;
using base::make_not_null_unique;
using base::OFStream;
using base::not_null;
using base::OFStream;
using base::SerializeAsBytes;
using base::Status;
using geometry::AffineMap;
@@ -929,14 +930,34 @@ void Plugin::ComputeAndRenderNodes(
std::unique_ptr<DiscreteTrajectory<World>>& descending) const {
auto const trajectory_in_plotting =
renderer_->RenderBarycentricTrajectoryInPlotting(begin, end);

auto const* const cast_plotting_frame = dynamic_cast<
BodyCentredNonRotatingDynamicFrame<Barycentric, Navigation> const*>(
&*renderer_->GetPlottingFrame());
// The body-centred non rotating frame does not rotate; its reference plane is
// not an inherent dynamical property. When using this frame, discard the
// nodes if they are far enough from the central body that its equator is
// irrelevant.
Length const threshold =
cast_plotting_frame == nullptr
? Infinity<Length>()
: EquatorRelevanceThreshold(
*dynamic_cast_not_null<RotatingBody<Barycentric> const*>(
cast_plotting_frame->centre()));
auto const show_node = [threshold](DegreesOfFreedom<Navigation> const& dof) {
return (dof.position() - Navigation::origin).Norm() < threshold;
};

DiscreteTrajectory<Navigation> ascending_trajectory;
DiscreteTrajectory<Navigation> descending_trajectory;
// The so-called North is orthogonal to the plane of the trajectory.
ComputeNodes(trajectory_in_plotting->Begin(),
trajectory_in_plotting->End(),
Vector<double, Navigation>({0, 0, 1}),
ascending_trajectory,
descending_trajectory);
descending_trajectory,
show_node);

ascending = renderer_->RenderPlottingTrajectoryInWorld(
current_time_,
ascending_trajectory.Begin(),
113 changes: 44 additions & 69 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -1879,20 +1879,17 @@ private void RenderPredictionMarkers(String vessel_guid,
ascending_nodes_iterator,
MapObject.ObjectType.AscendingNode,
MapNodePool.NodeSource.PREDICTION,
vessel : target,
celestial : plotting_frame_selector_.selected_celestial);
plotting_frame_selector_);
map_node_pool_.RenderMarkers(
descending_nodes_iterator,
MapObject.ObjectType.DescendingNode,
MapNodePool.NodeSource.PREDICTION,
vessel : target,
celestial : plotting_frame_selector_.selected_celestial);
plotting_frame_selector_);
map_node_pool_.RenderMarkers(
approaches_iterator,
MapObject.ObjectType.ApproachIntersect,
MapNodePool.NodeSource.PREDICTION,
vessel : target,
celestial : plotting_frame_selector_.selected_celestial);
plotting_frame_selector_);
} else {
foreach (CelestialBody celestial in
plotting_frame_selector_.FixedBodies()) {
@@ -1906,40 +1903,31 @@ private void RenderPredictionMarkers(String vessel_guid,
apoapsis_iterator,
MapObject.ObjectType.Apoapsis,
MapNodePool.NodeSource.PREDICTION,
vessel : null,
celestial : celestial);
plotting_frame_selector_);
map_node_pool_.RenderMarkers(
periapsis_iterator,
MapObject.ObjectType.Periapsis,
MapNodePool.NodeSource.PREDICTION,
vessel : null,
celestial : celestial);
plotting_frame_selector_);
}
var frame_type = plotting_frame_selector_.frame_type;
if (frame_type ==
ReferenceFrameSelector.FrameType.BARYCENTRIC_ROTATING ||
frame_type == ReferenceFrameSelector.FrameType
.BODY_CENTRED_PARENT_DIRECTION) {
var primary =
plotting_frame_selector_.selected_celestial.referenceBody;
plugin_.RenderedPredictionNodes(
vessel_guid,
sun_world_position,
out DisposableIterator ascending_nodes_iterator,
out DisposableIterator descending_nodes_iterator);
map_node_pool_.RenderMarkers(
ascending_nodes_iterator,
MapObject.ObjectType.AscendingNode,
MapNodePool.NodeSource.PREDICTION,
vessel : null,
celestial : primary);
map_node_pool_.RenderMarkers(
descending_nodes_iterator,
MapObject.ObjectType.DescendingNode,
MapNodePool.NodeSource.PREDICTION,
vessel : null,
celestial : primary);
}
var primary =
plotting_frame_selector_.selected_celestial.referenceBody;
plugin_.RenderedPredictionNodes(
vessel_guid,
sun_world_position,
out DisposableIterator ascending_nodes_iterator,
out DisposableIterator descending_nodes_iterator);
map_node_pool_.RenderMarkers(
ascending_nodes_iterator,
MapObject.ObjectType.AscendingNode,
MapNodePool.NodeSource.PREDICTION,
plotting_frame_selector_);
map_node_pool_.RenderMarkers(
descending_nodes_iterator,
MapObject.ObjectType.DescendingNode,
MapNodePool.NodeSource.PREDICTION,
plotting_frame_selector_);
}
}

@@ -1960,20 +1948,17 @@ private void RenderFlightPlanMarkers(String vessel_guid,
ascending_nodes_iterator,
MapObject.ObjectType.AscendingNode,
MapNodePool.NodeSource.FLIGHT_PLAN,
vessel : target,
celestial : plotting_frame_selector_.selected_celestial);
plotting_frame_selector_);
map_node_pool_.RenderMarkers(
descending_nodes_iterator,
MapObject.ObjectType.DescendingNode,
MapNodePool.NodeSource.FLIGHT_PLAN,
vessel : target,
celestial : plotting_frame_selector_.selected_celestial);
plotting_frame_selector_);
map_node_pool_.RenderMarkers(
approaches_iterator,
MapObject.ObjectType.ApproachIntersect,
MapNodePool.NodeSource.FLIGHT_PLAN,
vessel : target,
celestial : plotting_frame_selector_.selected_celestial);
plotting_frame_selector_);
} else {
foreach (CelestialBody celestial in
plotting_frame_selector_.FixedBodies()) {
@@ -1987,40 +1972,30 @@ private void RenderFlightPlanMarkers(String vessel_guid,
apoapsis_iterator,
MapObject.ObjectType.Apoapsis,
MapNodePool.NodeSource.FLIGHT_PLAN,
vessel : null,
celestial : celestial);
plotting_frame_selector_);
map_node_pool_.RenderMarkers(
periapsis_iterator,
MapObject.ObjectType.Periapsis,
MapNodePool.NodeSource.FLIGHT_PLAN,
vessel : null,
celestial : celestial);
}
var frame_type = plotting_frame_selector_.frame_type;
if (frame_type ==
ReferenceFrameSelector.FrameType.BARYCENTRIC_ROTATING ||
frame_type == ReferenceFrameSelector.FrameType
.BODY_CENTRED_PARENT_DIRECTION) {
var primary =
plotting_frame_selector_.selected_celestial.referenceBody;
plugin_.FlightPlanRenderedNodes(
vessel_guid,
sun_world_position,
out DisposableIterator ascending_nodes_iterator,
out DisposableIterator descending_nodes_iterator);
map_node_pool_.RenderMarkers(
ascending_nodes_iterator,
MapObject.ObjectType.AscendingNode,
MapNodePool.NodeSource.FLIGHT_PLAN,
vessel : null,
celestial : primary);
map_node_pool_.RenderMarkers(
descending_nodes_iterator,
MapObject.ObjectType.DescendingNode,
MapNodePool.NodeSource.FLIGHT_PLAN,
vessel : null,
celestial : primary);
plotting_frame_selector_);
}
var primary =
plotting_frame_selector_.selected_celestial.referenceBody;
plugin_.FlightPlanRenderedNodes(
vessel_guid,
sun_world_position,
out DisposableIterator ascending_nodes_iterator,
out DisposableIterator descending_nodes_iterator);
map_node_pool_.RenderMarkers(
ascending_nodes_iterator,
MapObject.ObjectType.AscendingNode,
MapNodePool.NodeSource.FLIGHT_PLAN,
plotting_frame_selector_);
map_node_pool_.RenderMarkers(
descending_nodes_iterator,
MapObject.ObjectType.DescendingNode,
MapNodePool.NodeSource.FLIGHT_PLAN,
plotting_frame_selector_);
}
}

Loading