Billiard simulation improvements

August 6, 2013 at 10:17 AMMichele Mottini

I just uploaded a new version of the billiard simulation with various improvements. The source code is on GitHub.


Previous versions did not properly scale the simulation, 1 pixels was equivalent to 1 meter and so the balls (and their speed) were actually gigantic. The new version correctly scales dimensions: the balls are the size of real billiard balls and the table size is standard as well.

The correct scaling produces a noticeable difference in the time required for the balls to come to a complete stop: rolling resistance causes a constant deceleration, so with the original high speeds the balls took a very long time to stop, now with realistic speeds the balls stop quite quickly.

Initial balls configuration

It is possible to choose between a list of possible initial balls configuration using a drop-down, and also to directly select the initial configuration in the URL using an ‘init=<configuration name>’  option – e.g. ‘/rpool/?init=fromLeftTwoVertical

Start/stop and velocity display

The simulation can be stopped and re-started using the ‘Start’ and ‘Stop’ buttons. When it is stopped the ‘Step’ button executes a single update step at each click.

By default the simulation starts automatically, but this can be changed adding a `stop=’ option to the URL – e.g. ‘/rpool/?init=fromLeftTwoVertical&stop=’.

When the simulation is stopped the velocity of each ball is displayed as an arrow:


Double collisions

The simulation can now optionally handle double collision as described in a previous post. To enable it use either the ‘Handle double collisions’ check-box in the page or the ‘double’ option in the URL – e.g. ‘/rpool/?init=fromLeftTwoVertical&double=


It is possible to change the value of the coefficients of restitution and of rolling resistance used in the simulation. Setting the coefficients of restitution to 1 gives perfect elastic collisions, and setting then to 0 gives perfect inelastic ones: balls ‘stick’ to each other and to the table’s side when they collide.

Posted in: Programming

Tags: ,

Add comment

  Country flag

  • Comment
  • Preview