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

Relative Velocity Calculation Adjustment #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ReedKimble
Copy link

In translating this code to a VB.Net implementation, it was found that objects would build up angular velocity until they "exploded" against one another. This is most evident if you create an open "box" of fixed colliders and then drop an assortment of polygons and circles into the box.

Thanks to assistance from this thread (https://social.msdn.microsoft.com/Forums/vstudio/en-US/65526d49-5107-4ffc-b25e-1b5a619afcb3/2d-rigidbody-physics-engine-bug?forum=vbgeneral) it was determined that the rv values should be calculated with subtraction on both terms:

"And both minus (b.vel - ... and a.vel - ...) (not both plus), because of viewing from A to B (standing on the edge of A looking at the mass-point of B moving by -> standing on earth watching a shootingstar)"

The two changes proposed in this file solved the issue and the translated code works exactly as expected now.

PS. Thanks so much for creating this and the associated articles on your blog! Amazing, wonderful, outstanding work!!

In translating this code to a VB.Net implementation, it was found that objects would build up angular velocity until they "exploded" against one another.  This is most evident if you create an open "box" of fixed colliders and then drop an assortment of polygons and circles into the box.

Thanks to assistance from this thread (https://social.msdn.microsoft.com/Forums/vstudio/en-US/65526d49-5107-4ffc-b25e-1b5a619afcb3/2d-rigidbody-physics-engine-bug?forum=vbgeneral) it was determined that the rv values should be calculated with subtraction on both terms:

"And both minus (b.vel - ... and a.vel - ...) (not both plus), because of viewing from A to B (standing on the edge of A looking at the mass-point of B moving by -> standing on earth watching a shootingstar)"

The two changes proposed in this file solved the issue and the translated code works exactly as expected now.

PS. Thanks so much for creating this and the associated articles on your blog!  Amazing, wonderful, outstanding work!!
@i-make-robots
Copy link

Hi!

Vec2 rv = B->velocity + Cross( B->angularVelocity, rb ) -
          A->velocity - Cross( A->angularVelocity, ra );

is derived from https://en.wikipedia.org/wiki/Collision_response eq (3),

so as i understand it's really

Vec2 rv = (B->velocity + Cross( B->angularVelocity, rb )) -
          (A->velocity + Cross( A->angularVelocity, ra ));

does making them both minus really work, or is it causing the system to lose energy faster than it should?

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.

2 participants