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

Commits on Dec 29, 2019

  1. Inverse the rotations.

    pleroy committed Dec 29, 2019
    Copy the full SHA
    a565b26 View commit details
  2. Merge pull request #2420 from pleroy/InverseRotations

    Invert the diagonalization rotations for consistency with EulerSolver
    pleroy authored Dec 29, 2019
    Copy the full SHA
    eb4e48e View commit details
2 changes: 1 addition & 1 deletion geometry/symmetric_bilinear_form.hpp
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ class SymmetricBilinearForm {
template<typename Eigenframe>
struct Eigensystem {
SymmetricBilinearForm<Scalar, Eigenframe> form;
Rotation<Frame, Eigenframe> rotation;
Rotation<Eigenframe, Frame> rotation;
};

// Computes a form equivalent to the current one but diagonalized with
2 changes: 1 addition & 1 deletion geometry/symmetric_bilinear_form_body.hpp
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ SymmetricBilinearForm<Scalar, Frame>::Diagonalize() const {
auto const v₀ = Vector<double, Frame>(PickEigenvector(m₀));
auto const v₁ = Vector<double, Frame>(PickEigenvector(m₁));

Rotation<Frame, Eigenframe> const rotation{v₀, v₁, Wedge(v₀, v₁)};
Rotation<Eigenframe, Frame> const rotation{v₀, v₁, Wedge(v₀, v₁)};
return {form, rotation};
}

12 changes: 6 additions & 6 deletions geometry/symmetric_bilinear_form_test.cpp
Original file line number Diff line number Diff line change
@@ -264,15 +264,15 @@ TEST_F(SymmetricBilinearFormTest, Diagonalize) {
Vector<double, World> const w₀({ 0, 1, 0});
Vector<double, World> const w₁({-1, 0, 0});
Vector<double, World> const w₂({ 0, 0, 1});
EXPECT_THAT(f_eigensystem.rotation(w₀),
EXPECT_THAT(f_eigensystem.rotation.Inverse()(w₀),
Componentwise(AlmostEquals(1, 0),
VanishesBefore(1, 1),
VanishesBefore(1, 0)));
EXPECT_THAT(f_eigensystem.rotation(w₁),
EXPECT_THAT(f_eigensystem.rotation.Inverse()(w₁),
Componentwise(VanishesBefore(1, 2),
AlmostEquals(1, 0),
VanishesBefore(1, 0)));
EXPECT_THAT(f_eigensystem.rotation(w₂),
EXPECT_THAT(f_eigensystem.rotation.Inverse()(w₂),
Componentwise(VanishesBefore(1, 0),
VanishesBefore(1, 0),
AlmostEquals(1, 0)));
@@ -305,15 +305,15 @@ TEST_F(SymmetricBilinearFormTest, Diagonalize) {
Vector<double, World> const w₂({0.50207513078793658603,
0.52940122795673242036,
0.68385298338325629274});
EXPECT_THAT(f_eigensystem.rotation(w₀),
EXPECT_THAT(f_eigensystem.rotation.Inverse()(w₀),
Componentwise(AlmostEquals(1, 0),
VanishesBefore(1, 0),
VanishesBefore(1, 0)));
EXPECT_THAT(f_eigensystem.rotation(w₁),
EXPECT_THAT(f_eigensystem.rotation.Inverse()(w₁),
Componentwise(VanishesBefore(1, 0),
AlmostEquals(1, 0),
VanishesBefore(1, 0)));
EXPECT_THAT(f_eigensystem.rotation(w₂),
EXPECT_THAT(f_eigensystem.rotation.Inverse()(w₂),
Componentwise(VanishesBefore(1, 1),
VanishesBefore(1, 2),
AlmostEquals(1, 0)));
10 changes: 5 additions & 5 deletions physics/inertia_tensor.hpp
Original file line number Diff line number Diff line change
@@ -58,16 +58,16 @@ class InertiaTensor {
InertiaTensor<ToFrame> Transform(
RigidTransformation<Frame, ToFrame> const& transformation) const;

// A factory that creates an inertia tensor for a solid sphere of water having
// the given mass. Useful e.g. for save compatibility.
static InertiaTensor<Frame> MakeWaterSphereInertiaTensor(Mass const& mass);

template<typename PrincipalAxesFrame>
struct PrincipalAxes {
R3Element<MomentOfInertia> moments_of_inertia;
Rotation<Frame, PrincipalAxesFrame> rotation;
Rotation<PrincipalAxesFrame, Frame> rotation;
};

// A factory that creates an inertia tensor for a solid sphere of water having
// the given mass. Useful e.g. for save compatibility.
static InertiaTensor<Frame> MakeWaterSphereInertiaTensor(Mass const& mass);

// Diagonalization is possible in any frame, but it's mostly used in a frame
// centred at the centre of mass.
template<typename PrincipalAxesFrame>
4 changes: 2 additions & 2 deletions physics/inertia_tensor_body.hpp
Original file line number Diff line number Diff line change
@@ -100,10 +100,10 @@ InertiaTensor<Frame>::Diagonalize() const {

auto const y = Bivector<double, IntermediateFrame>({0, 1, 0});
auto const z = Bivector<double, IntermediateFrame>({0, 0, 1});
Rotation<IntermediateFrame, PrincipalAxesFrame> const swap_x_and_z(
Rotation<PrincipalAxesFrame, IntermediateFrame> const swap_x_and_z(
z, y, Commutator(z, y));

return {moments_of_inertia, swap_x_and_z * eigensystem.rotation};
return {moments_of_inertia, eigensystem.rotation * swap_x_and_z};
}

template<typename Frame>