Skip to content

BUG: Incorrect vector rotation in GenericSurface.compute_forces_and_moments #932

Description

@zuorenchen

Describe the bug

Incorrect vector rotation in GenericSurface.compute_forces_and_moments().
Here, we want to represent the black L, D, Q vectors in the blue body frame.

The M_BA matrix should be direction cosine matrix (DCM), however it is given in vector rotation matrices. Vector rotation matrices rotate the vector without changing/rotating reference frame.

Current implementation rotates the force vectors to match body axis, but results are however presented in aero frame.

If it is intended to use rotation matrix instead of DCM, the rotation should be:

  • Start with the Q, L, D vectors matching +X, -Y, -Z in body frame (i.e. Vector([side, -lift, -drag]) )
  • Rotate the vector by -alpha on X axis and beta on Y axis.
  • The results will match the black Q, L, D vectors and presented in body frame

Another POV:

  • Only focus on blue Zb axis and body frame.
  • Rotate the Zb axis by -alpha on X axis and beta on Y axis.
  • the result will match the black V vector
Image Image

To Reproduce & Expected behavior & Screenshots

Image

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Activity

  1. added
    BugSomething isn't working
    AerodynamicsAny problem to be worked on top of RocketPy's Aerodynamic
    on Mar 8, 2026
  2. self-assigned this
    on Mar 21, 2026
  3. ting-hong-shieh commented on Aug 14, 2026

    @ting-hong-shieh

    I reduced this to three unit force vectors at alpha = 0.2 rad and beta = 0.1 rad. Current develop is cb6106a717207dd8fc2dfe1446d80ff75022f21b.

    For the aerodynamic vector [Q, -L, -D], the current code applies the positive-alpha/negative-beta rotation. Applying the direction-cosine mapping Rx(-alpha) @ Ry(+beta) gives:

    Unit coefficient Current body result DCM body result
    side (Q=1) [0.995004165, -0.019833838, 0.097843395] [0.995004165, -0.019833838, -0.097843395]
    lift (L=1) [0, -0.980066578, -0.198669331] [0, -0.980066578, 0.198669331]
    drag (D=1) [0.099833417, 0.197676812, -0.975170327] [-0.099833417, -0.197676812, -0.975170327]

    Draft PR #1064, head 84d3b6a9f0b4a8074d764130dc3d189bdc402036, produces the DCM column for all three cases through its wind-to-body coefficient conversion. That makes it an implementation candidate for this issue, although #1064 contains a much broader aerodynamic refactor.

    Would you prefer to keep this fix and its three basis-vector regression cases in #1064, or split the rotation correction into a smaller PR against develop? I have not opened a duplicate while #932 is assigned and #1064 is active.

    Environment: Python 3.12.6; NumPy 2.5.2; macOS 26.5.2 arm64.

  4. Gui-FernandesBR commented on Aug 14, 2026

    @Gui-FernandesBR
    Member

    @ting-hong-shieh let's wait until #1064 is merged please

  5. stephanLouw commented on Sep 17, 2026

    @stephanLouw

    @ting-hong-shieh Does this bug mean that using Generic surface in the current PyPi version (1.13.0), will lead to a wrong flight prediction?

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

Metadata

Metadata

Assignees

Labels

AerodynamicsAny problem to be worked on top of RocketPy's AerodynamicBugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions