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

Commits on May 15, 2020

  1. Copy the full SHA
    f6b4412 View commit details

Commits on May 16, 2020

  1. after pleroy’s review

    eggrobin committed May 16, 2020
    Copy the full SHA
    a94cd1c View commit details
  2. Merge pull request #2572 from eggrobin/euler-solver-functions

    New member functions for EulerSolver
    eggrobin authored May 16, 2020
    Copy the full SHA
    1d9f60a View commit details
Showing with 48 additions and 0 deletions.
  1. +13 −0 physics/euler_solver.hpp
  2. +35 −0 physics/euler_solver_body.hpp
13 changes: 13 additions & 0 deletions physics/euler_solver.hpp
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
#include "geometry/r3_element.hpp"
#include "geometry/rotation.hpp"
#include "geometry/signature.hpp"
#include "physics/rigid_motion.hpp"
#include "quantities/named_quantities.hpp"
#include "quantities/quantities.hpp"
#include "serialization/physics.pb.h"
@@ -55,6 +56,8 @@ class EulerSolver {
AttitudeRotation const& initial_attitude,
Instant const& initial_time);

R3Element<MomentOfInertia> const& moments_of_inertia() const;

// Computes the angular momentum at the given time in the principal axes.
// This is mostly useful as input to the following two functions.
Bivector<AngularMomentum, PrincipalAxesFrame> AngularMomentumAt(
@@ -70,6 +73,16 @@ class EulerSolver {
Bivector<AngularMomentum, PrincipalAxesFrame> const& angular_momentum,
Instant const& time) const;

// Equivalent to this->AttitudeAt(this->AngularMomentumAt(time), time), where
// the angular momentum is not needed.
AttitudeRotation AttitudeAt(Instant const& time) const;

// The motion of the body at the given time. The centre of gravity of the
// body moves according to |linear_motion|.
RigidMotion<PrincipalAxesFrame, InertialFrame> MotionAt(
Instant const& time,
DegreesOfFreedom<InertialFrame> const& linear_motion) const;

void WriteToMessage(not_null<serialization::EulerSolver*> message) const;
static EulerSolver ReadFromMessage(serialization::EulerSolver const& message);

35 changes: 35 additions & 0 deletions physics/euler_solver_body.hpp
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ using geometry::Commutator;
using geometry::DeduceSignPreservingOrientation;
using geometry::DefinesFrame;
using geometry::Normalize;
using geometry::OrthogonalMap;
using geometry::Quaternion;
using geometry::Sign;
using geometry::Vector;
@@ -271,6 +272,12 @@ EulerSolver<InertialFrame, PrincipalAxesFrame>::EulerSolver(
}
}

template<typename InertialFrame, typename PrincipalAxesFrame>
R3Element<MomentOfInertia> const&
EulerSolver<InertialFrame, PrincipalAxesFrame>::moments_of_inertia() const {
return moments_of_inertia_;
}

template<typename InertialFrame, typename PrincipalAxesFrame>
Bivector<AngularMomentum, PrincipalAxesFrame>
EulerSolver<InertialFrame, PrincipalAxesFrame>::AngularMomentumAt(
@@ -398,6 +405,34 @@ EulerSolver<InertialFrame, PrincipalAxesFrame>::AttitudeAt(
}
}

template<typename InertialFrame, typename PrincipalAxesFrame>
typename EulerSolver<InertialFrame, PrincipalAxesFrame>::AttitudeRotation
EulerSolver<InertialFrame, PrincipalAxesFrame>::AttitudeAt(
Instant const& time) const {
return AttitudeAt(AngularMomentumAt(time), time);
}

template<typename InertialFrame, typename PrincipalAxesFrame>
RigidMotion<PrincipalAxesFrame, InertialFrame>
EulerSolver<InertialFrame, PrincipalAxesFrame>::MotionAt(
Instant const& time,
DegreesOfFreedom<InertialFrame> const& linear_motion) const {
Bivector<AngularMomentum, PrincipalAxesFrame> const angular_momentum =
AngularMomentumAt(time);
Rotation<PrincipalAxesFrame, InertialFrame> const attitude =
AttitudeAt(angular_momentum, time);
AngularVelocity<InertialFrame> const angular_velocity =
attitude(AngularVelocityFor(angular_momentum));

return RigidMotion<PrincipalAxesFrame, InertialFrame>(
RigidTransformation<PrincipalAxesFrame, InertialFrame>(
PrincipalAxesFrame::origin,
linear_motion.position(),
attitude.template Forget<OrthogonalMap>()),
angular_velocity,
linear_motion.velocity());
}

template<typename InertialFrame, typename PrincipalAxesFrame>
void EulerSolver<InertialFrame, PrincipalAxesFrame>::WriteToMessage(
not_null<serialization::EulerSolver*> const message) const {