Last edited 10/36/12 by beadswo2
Find this document at http://new.math.uiuc.edu/math198/ivanhoe ---fix

Elastic Collisions of Spheres and Flat-Faced Figures

Abstract

The purpose of this project was to investigate the process of collision detection and deflection in 3D computer graphics using VPython. I was first able to model elastic ball-on-ball collisions using conservation of momentum and energy. From there, I created a method for detecting collisions between spheres and polyhedrons, and calculating the resulting trajectories of the spheres. By building simple polyhedrons, I was then able to manufacture large and more complex shapes with which spheres could collide.

Project Files

shapegenerator.py

This is my main program. Shapegenerator.py can be used to create flat-faced 3D objects and balls that will collide with each other. In theory, the flat-faced figures created by shapegenerator.py can be unboundedly complex, however my lack of optimization means the display of these shapes will be unreasonably slow.

To make a polyhedron or complex flat-faced figure, a user simply creates the shape's sides, stitches them together with built in funcitons, and manipulates them in a 3D environment.

Conventionally, this program is to be used in tandem with an initialization program. To prevent clutter, a user simply creates balls and other figures in the initialization program. This program then uses shapegenerator.py to churn out a simulation. With slight modification, shapegenerator.py may also be used as a stand-alone program.

ballbouncer.py

The most basic of my core files. Used to make balls that will collide with each other. This is a standalone program. This program is easily edited to meet the needs of the user. Polyhedron creation is not supported, however.

ballgenerator2.py

A precursor to shapegenerator.py, this only creates and collides spheres. Because of a lack of optimization, if too many balls are created the program will lag severly. In an attempt to speed up simulations, I created a script-writing process that allows ball2generator.py to calculate the trajectories of each sphere and print these trajectories to an new render file. These new render files were then able to display, with considerable speed, complex interactions between many balls--sometimes up to 200.

What I have been able to do with my programs

These all took about 15 minutes with the aid of my programs.

Unexpected Rotational Motion

Without explicitly implementing rotational physics, certain scenarios exhibit rotational phenomena. I was surprised to find that, when two spheres are intertwined, they couple together and appear to rotate about a center of mass. What I found more suprising was, when I calculated and displayed the center of mass of two-ball systems, it traveled in straight lines at constant velocity--just as newtonian mechanics dictates! I cannot guaruantee the rotational motion is accurate, but it looks good and may be worth looking into in the future.

Documentation

A comprehensive documentation guide can be found here Here is gratuitous picture .
Table of Links
File Name Description
shapegenerator.py create spheres and flat-faced figures that bounce
base.py initialization program framework for shapegenerator.py
triangle.py example initialization program for shapegenerator.py. Needs shapegenerator.py to run. Run this file.
ballbouncer.py easy to edit sphere-colliding program
ballgenerator2.py create spheres and flat-faced figures that bounce
drag5.py an example initialization program for ballgenerator2.py. Needs ballgenerator2.py to run. Run this file.