Last edited 7may05 by vndrvnnt@uiuc.edu
Find this document at http://www.ncsa.uiuc.edu/Classes/MATH198/jvanderv

Vpool: A billiards simulation in Vpython

Abstract

Vpool is a 3-dimensional simulation of a game of pool.  Four balls interact by colliding with each other and the walls of the table.  To simplify the math, it is assumed that all collisions are fully elastic and as such, all kinetic energy is conserved.  The balls can also fall into the 6 different pockets.  Users interact with the program by striking the cue ball with a cue stick.  Balls slow down due to simulated friction and the user is allowed to hit again.  

 

User Input

User interact with the program using both the mouse and keyboard.  While the cue stick appears on the screen, the program continually inputs the coordinates of the mouse.  These coordinates are used to determine where the end of the cue stick should be.  The program takes the x-coordinate of the mouse and calculates an appropriate y-coordinate so that the end of the cue will move around the cue ball in a circle of radius 6 (this is the length of the cue).  Therefore, by simply moving the mouse left and right, the user can rotate the cue stick around the ball.  If the absolute value of the x-coordinate exceeds 6, the y-coordinates switch sign so that the cue faces in the opposite y direction.  This allows for 360 degrees of rotation.  The user left-clicks the mouse to shoot the ball in the direction that the cue is pointed.  Once the balls have stopped due to the simulated friction, striking spacebar will bring the cue stick back and allow the user to shoot again.

 

Future Improvements

I hope that others will continue to improve my program, making it more realistic and allowing for more user-interaction.  There are several things that I would have wanted to add had time permitted:

- Add More Balls

- Allow user to add spin by hitting different parts of the cue ball

- Allow balls to move in 3-dimensions

- Allow user to control how hard he hits the cue ball

- Improve the accuracy of the collision detection