Final Project:  Collision Detection

Collision detection algorithms are necessary in such fields as robotics, motion planning, computer
graphics, virtual reality, and video games.  It is useful to turn off collision detection when a bug in your favorite first-person-shooter has you trapped in a room with no exits, but in real life we have
no such access to the laws of physics:  if you run into a wall your velocity will change, and you
can not pass to the other side of the wall without resorting to extreme measures, such as removing the wall.  Collision detection algorithms capture this principle in the language of the computer.

It is useful to create a simulation of a robot and its environment before actually attempting to
build the robot.  In real life, an autonomous robot designed to vacuum the floor would be quite
unfit if it had no way to recognize when it was opposed by an obstacle.  Therefore, it is necessary
to build this feature into the simulation.  The physical form of the world and the objects within are  represented by polygons or polyhedra.  In a two dimensional simulation one could
compute the intersection of two polygons to detect collision:  if the intersection exists, then there
has been a collision.  Sometimes it is sufficient to know only whether or not there has been
a collision, and other times it might be necessary to know exactly where the collision has occurred.

 Illustration

The next section describes a game I have implemented and a related collision detection
problem that I would like to solve and implement.

The game is inspired by:

Asteroids, 1979, by Atari.

and

Braitenberg, Valentino.  Vehicles, experiments in synthetic psychology.  MIT Press,
    c1984.  Cambridge, Mass. 152 p.

Asteroids takes place in a two-dimensional toroidal world, populated with asteroids and
the player's ship.  The goal is to shoot the asteroids, breaking them into smaller pieces
until they are no longer a threat, while not allowing yourself to be hit by the asteroids. 

Essentially what I have done is replace the asteroids in Asteroids with robots which are
controlled by simple neural networks after the fashion of chapters 1-3 in Braitenberg.

 Illustration of neural network and position update method 

The robots seek to avoid collisions with each other and with missiles fired by the player's
ship.  They seek to collide with the player's ship.

When a missile hits a robot, one of the connections in its neural network is chosen randomly and broken.

Currently a bounding circle is used for collision detection.  I would like for the robots to have
some armor, in the form of a convex polygon which would surround the neural network.
The player would have to blast through this armor in order to damage the
brain underneath.  I would like for the collision detection to be more realistic, such that
specific portions of armor or a specific connection in the network could be targeted by
the player.  More realistic collision detection will likely lead to higher computational
complexity.

These figures illustrate an idea I had for more realistic collision detection.  Beginning
with a naive algorithm - check each edge of the polygon for intersection with some point.

Position the polygon so its center is at or near the origin.

Break the polygon into four chains - one chain for each quadrant in the plane.

1st quad.

2nd quad.

3rd quad.

4th quad.

When it comes time to check for a collision, see which quadrant - relative to the
polygon - the foreign object is in, then test for intersection with only the edges
which are in the same quadrant.  Notice that some special provision must be made
if the coordinate axes intersect with an edge of the polygon.

Some collision detection links:

 http://www.magic-software.com/gr_coll.htm
 http://www.ams.sunysb.edu/~jklosow/quickcd/QuickCD.html
 http://compgeom.cs.uiuc.edu/~jeffe/pubs/kollide.html
 http://compgeom.cs.uiuc.edu/~jeffe/pubs/cdsimple.html