File Exchange

image thumbnail

Billiards

version 1.1.0.0 (4.32 KB) by Peter van Alem
Simulation of elastic collisions of balls of different sizes.

9 Downloads

Updated 29 Oct 2011

View License

Purely elastic collisions.

Cite As

Peter van Alem (2020). Billiards (https://www.mathworks.com/matlabcentral/fileexchange/20759-billiards), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

nice simulation, but difficult to stop. Thanks

mohamed

it is nice program but when stops simulation
thanks

Rob Campbell

Nice effect. Downside is that code is somewhat confusingly laid out and it would benefit from vectorizing.

Seungho Choi

What a shammy progrram :P
U are king wang jjang

Francesco Pozzi

I like your simulation. I would appreciate if you could comment the code more extensively, use better the vectorization, follow the hints of Guillaume Jacquenot.

Perhaps you could insert a button to start and to stop the simulation, ask the user to choose the speed or other parameters (you could make a graphical user interface, a gui).

jichao zhao

that is excellent job. many thanks for sharing

Jack Fowley

Works very nice. Great simulation!

Guillaume Jacquenot

Nice program
However you do not exploit MatLab matrix computation abilities: You should avoid as much as possible "for" loop, which are really time consuming. In your case, Have a look to the meshgrid command. I bet you can remove all "for" loops except for the plot command.

You can also add a test to analyze the number input argument such as
if nargin == 0
NumberOfBalls = 10
end

The function normr is not a standard function, which people may not have with standard MatLab

You should also recommend the maximum number of balls, and alert in case of huge number.

Updates

1.1.0.0

Two and three dimensional simulation, more use of vectorization and a minor bug is fixed.

1.0.0.0

Some commentary is used to improve the code.

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux