Code covered by the BSD License  

Highlights from
Billiard Ball Animation

image thumbnail
from Billiard Ball Animation by Fahad Al Mahmood
This program animates the movement of a billiard ball.

[width,height,x0,y0,v0,th,mu,e,t_int,FILE]=billiard_input
% This is the User Input Section of the (Billiard Table) program

function [width,height,x0,y0,v0,th,mu,e,t_int,FILE]=billiard_input

width=input('Enter the Table Width: ');
height=input('Enter the Table Height: ');
x0=input('Enter the Initial X-coordinate of the Billiard Ball: ');

while x0<0 | x0>width
    disp(['Error! Try Again! Enter a number between 0 & ',num2str(width),': '])
    x0=input(' ');
end

y0=input('Enter the Initial Y-coordinate of the Billiard Ball: ');

while y0<0 | y0>height
    disp(['Error! Try Again! Enter a number between 0 & ',num2str(width),': '])
    y0=input(' ');
end

v0=input('Enter the Initial Velocity of the Billiard Ball: ');
th=input('Enter the Initial Angle of the Billiard Ball  (degrees): ');
mu=input('Enter the Billiard Table Coefficient of Friction: ');
e=input('Enter the Billiard Table Sides Coefficient of Restitution: ');
t_int=input('Enter the Time Frame Intervale: ');
FILE=input('Enter Data File Name (ex. data): ','s');

Contact us at files@mathworks.com