Skip to content

Fix the angular velocity returned by Frames.from_T_inv - #4855

Open
hubertus65 wants to merge 1 commit into
modelica:masterfrom
hubertus65:fix-from-T-inv-w
Open

hubertus65 wants to merge 1 commit into
modelica:masterfrom
hubertus65:fix-from-T-inv-w

Conversation

@hubertus65

Copy link
Copy Markdown
Member

Modelica.Mechanics.MultiBody.Frames.from_T_inv(T_inv, w) documents its input w as the angular velocity of frame 1 with respect to frame 2, resolved in frame 1 (skew(w) = T_inv*der(transpose(T_inv))). The orientation object stores R.w, the angular velocity of frame 2 with respect to frame 1, resolved in frame 2 (skew(R.w) = T*der(transpose(T)) with T = transpose(T_inv)).

Differentiating transpose(T_inv)*T_inv = identity(3) gives

skew(R.w) = transpose(T_inv)*der(T_inv) = -transpose(T_inv)*skew(w)*T_inv = -skew(transpose(T_inv)*w)

so R.w = -transpose(T_inv)*w. The function returned R.w = -w, which is only correct when w is parallel to the rotation axis (e.g. planar rotations). Frames.inverseRotation already does the analogous change of frame, w = -resolve1(R, R.w).

This PR changes

R := Orientation(T=transpose(T_inv),w= -w);

to

R := Orientation(T=transpose(T_inv),w= -transpose(T_inv)*w);

No model in the MSL calls Frames.from_T_inv, so no reference results change.

Test: with T = axesRotations({1, 2, 3}, {0.3, -0.2, 0.5}) and w = {0.1, 0.2, 0.3}, from_T_inv(transpose(T), w) now returns R.T = T and R.w = -T*w. Found by a new ModelicaTest coverage test, which will be proposed separately.

🤖 Generated with Claude Code

The input w is the angular velocity of frame 1 w.r.t. frame 2, resolved in
frame 1 (skew(w) = T_inv*der(transpose(T_inv))). The orientation object
stores the angular velocity of frame 2 w.r.t. frame 1, resolved in frame 2,
which is -transpose(T_inv)*w. Returning -w is only correct when w is
parallel to the rotation axis.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HansOlsson

Copy link
Copy Markdown
Contributor

I assume an alternative would be to just update the documentation to be consistent with current behavior.

hubertus65 added a commit to hubertus65/ModelicaStandardLibrary that referenced this pull request Nov 3, 2026
The case lists now run on Modelon Impact with this branch's Modelica,
ModelicaServices, Complex and ModelicaTest instead of Impact's built-in
MSL 4.1.0 (see ReviewResults/README.md for the workspace setup).

- Move AnalogOpAmpLimited, MutualInductor, TestQuadrature,
  TestFramesSmallRotation, ComplexStep and ComplexMathConjugateIfExpressions
  back from OpenModelica to the Impact lists, and remove the emptied
  OpenModelica lists of ComplexBlocks, Electrical, Math and Mechanics.
- Enable TestLAPACKdhgeqz (PR modelica#4854) and TestFramesFromTinv (PR modelica#4855).
- Regenerate baselines, results, HTML reports (25 cases per page) and CSV.

All checks of the 14 Impact case lists pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@beutlich beutlich added the L: Mechanics.MultiBody Issue addresses Modelica.Mechanics.MultiBody label Nov 4, 2026
@MatthiasBSchaefer MatthiasBSchaefer added the ready_for_ci allow regression testing ci to run (if c-code changed or pull request from non-member) label Nov 17, 2026
@MSL-RegressionTesting-CI

Copy link
Copy Markdown

@MatthiasBSchaefer

Copy link
Copy Markdown
Contributor

It seems like Modelica.Mechanics.MultiBody.Frames.from_T_inv is never used in Modelica or ModelicaTest. Such, the regression-testing is without any meaning.
An example model using this function should be added to ModelicaTest

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: Mechanics.MultiBody Issue addresses Modelica.Mechanics.MultiBody ready_for_ci allow regression testing ci to run (if c-code changed or pull request from non-member)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants