Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A class to implement the inertia tensor #2367

Merged
merged 31 commits into from
Oct 27, 2019

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Oct 26, 2019

No description provided.

// such that its origin is at the given points, with the axes of the frames
// coïnciding. This effectively defines ToFrame.
template<typename ToFrame>
InertiaTensor<ToFrame> Translate(Position<Frame> const& point) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expose a function that transforms the inertia tensor with a given RigidTransformation, keeping Translate and Rotate as underlying internals.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (well, Translate and Rotate are gone).

physics/inertia_tensor.hpp Outdated Show resolved Hide resolved
// ⎛ Σ(y² + z²) -xy -xy ⎞
// ⎜ -yx Σ(x² + z²) -yz ⎟
// ⎝ -zx -zy Σ(x² + y²) ⎠
// ⎛ ∑(y² + z²) -xy -xy ⎞
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't all entries sums, not just the diagonal?

Alternatively you could give the moment of inertia of a point mass and get rid of the sums entirely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love ∑.

auto const& linear_map = transformation.linear_map();

Displacement<ToFrame> const translation =
identity(from_origin - Frame::origin) - (to_origin - ToFrame::origin);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be linear_map, not identity; please get rid of the identity altogether, it is incorrect by definition: linear_map is the unique correct transformation between Vector<S, Frame> and Vector<S, ToFrame>.

Further, linear_map(from_origin - Frame::origin) - (to_origin - ToFrame::origin) is just ToFrame::Origin - transformation(Frame::origin); use that, and revert the changes to affine_map.hpp: from_origin and to_origin need not be exposed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All done.

Sorry, something went wrong.


Displacement<ToFrame> const translation =
identity(from_origin - Frame::origin) - (to_origin - ToFrame::origin);
SymmetricBilinearForm<Length, ToFrame> const translated_form =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just translated now, so the identifier is confusing.

Sorry, something went wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done too.

Rotation<IntermediateFrame, PrincipalAxesFrame> const swap_x_and_z(
Bivector<double, IntermediateFrame>({0, 0, 1}),
Bivector<double, IntermediateFrame>({0, 1, 0}),
Bivector<double, IntermediateFrame>({-1, 0, 0}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name the first two bivectors z and y, and pass Commutator(z, y) as the third argument so that correctness is obvious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@eggrobin eggrobin added the LGTM label Oct 27, 2019
@pleroy pleroy merged commit 079556e into mockingbirdnest:master Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants