-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
physics/inertia_tensor.hpp
Outdated
// 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
// ⎛ Σ(y² + z²) -xy -xy ⎞ | ||
// ⎜ -yx Σ(x² + z²) -yz ⎟ | ||
// ⎝ -zx -zy Σ(x² + y²) ⎠ | ||
// ⎛ ∑(y² + z²) -xy -xy ⎞ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love ∑.
physics/inertia_tensor_body.hpp
Outdated
auto const& linear_map = transformation.linear_map(); | ||
|
||
Displacement<ToFrame> const translation = | ||
identity(from_origin - Frame::origin) - (to_origin - ToFrame::origin); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All done.
physics/inertia_tensor_body.hpp
Outdated
|
||
Displacement<ToFrame> const translation = | ||
identity(from_origin - Frame::origin) - (to_origin - ToFrame::origin); | ||
SymmetricBilinearForm<Length, ToFrame> const translated_form = |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done too.
physics/inertia_tensor_body.hpp
Outdated
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})); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
No description provided.