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

Collisions with boundaries should stop at interesection point #3

Open
cwgreene opened this issue Apr 21, 2013 · 3 comments
Open

Collisions with boundaries should stop at interesection point #3

cwgreene opened this issue Apr 21, 2013 · 3 comments

Comments

@cwgreene
Copy link

Currently, the bounds are handled by forcing any particles outside of the bounds to be inside the bounds. However, since we're using verlet integration, this will result in an effective tangential acceleration (green vector) being applied to the body.

https://github.com/cwgreene/verlet-js/blob/master/images/error_type1.png?raw=true

This is visible by dragging the tire object in the demo to the left of the screen. Since the acceleration is applied downwards on the left hand side, the body rotates counter clockwise. When moved to the right hand side the acceleration will be applied upwards on the right hand side, again resulting in counter clockwise rotation.

I believe that by computing the intersection point (the origin of the green vector), and moving the particle there instead of the nearest bounding point (what is currently done), this issue will be resolved.

@cwgreene
Copy link
Author

Note that the proposed solution will result in the walls becoming 'sticky'. To make the collisions more elastic, the new position should actually be the reflected position across the boundary, and the old position should like wise be updated to be it's mirror image. This will get the next frame's velocity to be consistent.

@subprotocol
Copy link
Owner

I agree, this should fix the issue. Great callout! You are right, both position vectors will need to be updated. It should be possible to slip this functionality into the new bounds checking function on line 58: https://github.com/subprotocol/verlet-js/blob/master/js/verlet-js/verlet.js

@cwgreene
Copy link
Author

Implemented inelastic solution ('sticky' is the wrong word, 'soft' or 'absorbent' would have been better) for the left hand side and it works as expected.

Sample Solution:
cwgreene@2dbc721

I'm going to implement the generic bounding line solution.

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

No branches or pull requests

2 participants