Settings

Theme

Show HN: Minimalistic collisions simulation using TypeScript and HTML Canvas

github.com

2 points by mike31fr 2 years ago · 0 comments · 1 min read

Reader

Hey HN,

@atan2 submitted a great post 4 days ago about 2D rigid body collisions (https://news.ycombinator.com/item?id=40463764).

For what it's worth, here is a minimalistic simulation that I coded last year using TypeScript and HTML Canvas:

- Code: https://github.com/vandrieu/canvas-bouncing-ball

- Demo/Result: https://vandrieu.github.io/canvas-bouncing-ball

The main challenge was how to determine the angle and speed of each ball after a collision at a given angle.

I found the relevant theoretical material in the 2009 paper titled "2-Dimensional Elastic Collisions without Trigonometry" by Chad Berchek: https://www.vobarian.com/collisions/2dcollisions2.pdf

Please feel free to copy and use the code any way you wish.

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection