Showing posts with label Collisions. Show all posts
Showing posts with label Collisions. Show all posts

Monday, 19 March 2012

Ball-ball collisions

In this post I discussed how to handle collisions in general, at least when one of the objects is a ball for collision purposes. My intention was to follow it up with an example but I never got around to it. Well now I have, and it shows how to turn the theory in that post into practice.

Wednesday, 22 February 2012

Collision theory

My last two posts have shown how to do basic collisions without explaining why they work. In many cases it's not important to know why, and a lot can be done with just bouncing balls off walls and the floor. But the theory shows where the results come from, how they fit together and most important how to use it to solve other collision problems.

Tuesday, 21 February 2012

More ball-wall collisions

The observant among you might have noticed that the ball in my last test app was only bouncing off the floor not the wall. I've fixed this in a new version of the app, which improves on the previous version in another significant way.


It now bounces off both both walls as well as the floor, using essentially the same code, which is compact enough to reproduce in full:

Monday, 20 February 2012

ball-wall collisions

Collisions between a ball (in two or three dimensions) are perhaps the simplest to code. This is one consequence of the mathematical simplicity of ball physics, as discussed in my last post. As long as certain assumptions are made the code for such collisions is only a couple of very simple lines.