phetsims / collision-lab

"Collision Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 4 forks source link

branch: priori #123

Closed brandonLi8 closed 4 years ago

brandonLi8 commented 4 years ago

From design meeting, #122, #4, #6 is a problem for the sim. The proposal is to move the collision detection to a priori. Doing this in a branch.

brandonLi8 commented 4 years ago

In the commit above, I was able to predict ball to ball collisions before hand (priori) using a similar strategy to https://github.com/phetsims/collision-lab/blob/master/doc/images/ball-to-ball-time-of-impact-derivation.pdf except the time is forwards.

This was inspired by https://stackoverflow.com/questions/16902523/continuous-collision-detection-how-to-find-the-collision-according-to-these-2

Results are promising, but the collision response looks off. Investigating.

brandonLi8 commented 4 years ago

Spoke with @jonathanolson about this.

brandonLi8 commented 4 years ago

I've tested the priori collision engine from the commits above and it works mostly well. Lots of clean up work still needs to be done and on some occasions balls can get stuck inside of the border when it is turned on after Balls have escaped. I also need to look into rewiring ball path collision detection (https://github.com/phetsims/collision-lab/issues/75) and look into how the CollisionEngine subtypes are affected.

I'm also planning to remove the documentation files from #88 and rewrite new ones for this model.

brandonLi8 commented 4 years ago

Ball to ball collisions have been cleaned up and finished in the commits above. It works really really well. I tested for tunneling with extremely high velocity (in the order of ~20 m/s)/small radii balls and saw no tunneling from #122. I also tested with the query parameter?timeStepDuration=1 (time progressed when a step button is pressed) to simulate extremely slow frame rates and it all looked correct (both forwards and backwards).

However, I'm finding issues with ball-to-wall detection with ?timeStepDuration=1. For some reasons, the computation of how long before a ball-wall collision occurs fails when the ball hits near a corner with large time steps.

brandonLi8 commented 4 years ago

In the commit above, I found the fix to the ball-wall detection issue.

brandonLi8 commented 4 years ago

I've updated the CollisionEngine subtypes and I've merged this into master. Closing.