Skip to content

3D Ball-Ball Resolution#349

Draft
derek-mcblane wants to merge 2 commits into
ekiefl:mainfrom
derek-mcblane:3d-ball-ball-resolver
Draft

3D Ball-Ball Resolution#349
derek-mcblane wants to merge 2 commits into
ekiefl:mainfrom
derek-mcblane:3d-ball-ball-resolver

Conversation

@derek-mcblane
Copy link
Copy Markdown
Collaborator

@derek-mcblane derek-mcblane commented May 25, 2026

Implement ball-ball FrictionalInelastic3D to resolve #312.

This is based on branch 3d-ball-ball-detection, so the diff will make more sense after #342 is merged.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b6954bc7-2647-4240-8853-dd838a4c3f26

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 47.91%. Comparing base (0b344e7) to head (1e6d397).

Files with missing lines Patch % Lines
...resolve/ball_ball/frictional_inelastic/__init__.py 96.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #349      +/-   ##
==========================================
+ Coverage   47.75%   47.91%   +0.16%     
==========================================
  Files         159      159              
  Lines       10716    10734      +18     
==========================================
+ Hits         5117     5143      +26     
+ Misses       5599     5591       -8     
Flag Coverage Δ
service 47.91% <97.43%> (+0.16%) ⬆️
service-no-ani 58.37% <97.43%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines -18 to +31
@jit(nopython=True, cache=const.use_numba_cache)
def _resolve_ball_ball(rvw1, rvw2, R, u_b, e_b):
unit_x = np.array([1.0, 0.0, 0.0])

# rotate the x-axis to be in line with the line of centers
delta_centers = rvw2[0] - rvw1[0]
# FIXME3D: this should use quaternion rotation in 3D
theta = ptmath.angle(delta_centers, unit_x)
rvw1[1] = ptmath.coordinate_rotation(rvw1[1], -theta)
rvw1[2] = ptmath.coordinate_rotation(rvw1[2], -theta)
rvw2[1] = ptmath.coordinate_rotation(rvw2[1], -theta)
rvw2[2] = ptmath.coordinate_rotation(rvw2[2], -theta)
frame_rotation = ptmath.quaternion_from_vector_to_vector(delta_centers, unit_x)
rvw1 = quaternion.rotate_vectors(frame_rotation, rvw1)
rvw2 = quaternion.rotate_vectors(frame_rotation, rvw2)
rvw1, rvw2 = _resolve_ball_ball_x_normal(rvw1, rvw2, R, u_b, e_b)
rvw1 = quaternion.rotate_vectors(frame_rotation.conjugate(), rvw1)
rvw2 = quaternion.rotate_vectors(frame_rotation.conjugate(), rvw2)
return rvw1, rvw2
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This has some potential to change 2D behavior, so I will:

  • take a look at the ball-ball collision plots to verify the behavior is identical or near-identical

Comment on lines +26 to +30
rvw1 = quaternion.rotate_vectors(frame_rotation, rvw1)
rvw2 = quaternion.rotate_vectors(frame_rotation, rvw2)
rvw1, rvw2 = _resolve_ball_ball_x_normal(rvw1, rvw2, R, u_b, e_b)
rvw1 = quaternion.rotate_vectors(frame_rotation.conjugate(), rvw1)
rvw2 = quaternion.rotate_vectors(frame_rotation.conjugate(), rvw2)
Copy link
Copy Markdown
Collaborator Author

@derek-mcblane derek-mcblane May 25, 2026

Choose a reason for hiding this comment

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

It doesn't really make sense to rotate the r part of rvw. I should just leave r alone here and in the ball-cushion model that does something similar. It might introduce some error by doing a rotation then rotating it back.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

And same should be done to the existing ball cushion model

@derek-mcblane derek-mcblane force-pushed the 3d-ball-ball-resolver branch from 1e68809 to f36d066 Compare May 25, 2026 17:07
@derek-mcblane derek-mcblane force-pushed the 3d-ball-ball-resolver branch from f36d066 to 1e6d397 Compare May 26, 2026 14:54
@derek-mcblane derek-mcblane mentioned this pull request Jun 6, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[support-3d] B5. 3D ball-ball resolver: quaternion rotation + include z

1 participant