Add implementation of mjd_inertiaBoxFluid and Python test #2965
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added the function mjd_inertiaBoxFluid to compute the moment of inertia of a rectangular box of fluid (or solid) along its principal axes.
Includes a Python test script (test_inertiaBoxFluid.py) to verify correctness.
Necessary for MuJoCo simulations involving fluid-filled or box-shaped objects to have accurate inertia calculations.
Provides a foundation for eventual C integration in the MuJoCo engine.
how
Inputs: mass, x, y, z (dimensions of the box)
Outputs: Ixx, Iyy, Izz — moments of inertia about X, Y, Z axes.
Formula:
Ixx = mass * (y^2 + z^2) / 12
Iyy = mass * (x^2 + z^2) / 12
Izz = mass * (x^2 + y^2) / 12
Implemented in Python for testing and verification.
Python test script demonstrates correctness; integration into the MuJoCo C codebase can be done once a proper build environment is available.
Compatible with MuJoCo physics conventions and ready for review.