Skip to content
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

feature: Add DistanceJoint and 2D and 3D examples. #105

Merged
merged 4 commits into from
Aug 2, 2023

Conversation

shanecelis
Copy link
Sponsor Contributor

Hi,

This is a really cool project you've put together. I was using Rapier before this, and I really wanted a spring joint which isn't supported there. I hoped to find it here, but better than finding it I found that the XPBD means of expressing constraints and joints is so much easier to work with that I put one together myself that I hope you'll find useful.

Taking note from other XPBD implementations, I called this a DistanceJoint. When it's compliance does not equal 0 though it very much behaves like a spring joint.

I added examples in 2D and 3D. Here are some gifs on them.

distance_joint_2d

distance_joint_3d

One problem I didn't tackle was if you look at the heading describing a SphericalJoint and a DistanceJoint, they're not terribly distinct. However, upon inspection SphericalJoint is doing more than DistanceJoint. I wonder if there's a clearer way to discriminate between them in their one line descriptions.

Thanks for the code, and thanks for turning me onto the the XPBD methodology. Happy hacking!

@Jondolf Jondolf added C-Enhancement New feature or request C-Examples Improvements or additions to examples A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on labels Aug 2, 2023
@Jondolf
Copy link
Owner

Jondolf commented Aug 2, 2023

Thanks, looks great! I'm glad that the constraints are understandable enough that people can make new constraints like this.

The main difference between this distance constraint and the spherical joint is that the spherical joint doesn't allow any relative translation, while the distance constraint allows 1 or 2 (2D/3D) translational DOFs. The spherical joint also has optional swing and twist limits to constrain the relative orientation. I added a comment to clarify the DistanceJoint description a bit.

@shanecelis
Copy link
Sponsor Contributor Author

Thanks for the kind words and the explanation for the difference between distance joint and spherical joint.

Honestly after I wrote the code and started writing the documentation, I had a jolt when I saw spherical joint's description and I wondered if I had just reimplemented it for no benefit (other than my own challenge). Glad that wasn't the case.

Look forward to putting this to use. Thanks for the speedy reply. I'm impressed with the pace of work I've seen on this project.

@Jondolf
Copy link
Owner

Jondolf commented Aug 2, 2023

Thanks :)
Could you resolve the lint warnings so that I can get this merged? I think it's mostly whitespace stuff.

@shanecelis
Copy link
Sponsor Contributor Author

shanecelis commented Aug 2, 2023 via email

@Jondolf Jondolf merged commit 6443c27 into Jondolf:main Aug 2, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on C-Enhancement New feature or request C-Examples Improvements or additions to examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants