Skip to content

Commit

Permalink
Merge pull request #3431 from eggrobin/3430
Browse files Browse the repository at this point in the history
Fix the initialRotation
  • Loading branch information
eggrobin authored Aug 24, 2022
2 parents c977158 + e6a7fdb commit 04bb469
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ Rotation<CelestialSphere, World> Plugin::CelestialSphereRotation()

Angle Plugin::CelestialInitialRotation(Index const celestial_index) const {
auto const& body = *FindOrDie(celestials_, celestial_index)->body();
return body.AngleAt(game_epoch_);
// Offset by π/2 since |AngleAt| is with respect to the y axis of the
// celestial frame of the body, but KSP counts from the x axis.
return body.AngleAt(game_epoch_) + π / 2 * Radian;
}

Time Plugin::CelestialRotationPeriod(Index const celestial_index) const {
Expand Down
4 changes: 4 additions & 0 deletions ksp_plugin_adapter/config_node_parsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public static BodyParameters NewKeplerianBodyParameters(CelestialBody body,
// The origin of rotation in KSP is the x of Barycentric, rather
// than the y axis as is the case for Earth, so the right
// ascension is -90 deg.
// Note that once we set the positions and orientations of everything,
// that original x axis will become the y axis when |body| is the main
// body, and the |initialRotation| will be correspondingly increased by
// 90°.
reference_instant =
node?.GetAtMostOneValue("reference_instant") ?? "JD2451545.0",
min_radius = (body.pqsController?.radiusMin ?? body.Radius) + " m",
Expand Down

0 comments on commit 04bb469

Please sign in to comment.