Code covered by the BSD License
-
[width,height,x0,y0,v0,th,mu,...
This is the User Input Section of the (Billiard Table) program
-
billiard(manual_input)
-
tf=time_to_impact(width,heigh...
-
th=theta_impact(th,width,heig...
% This function recalculates the value of (Theta) depending on the impact
-
test_billiard.m
-
View all files
from
Billiard Ball Animation
by Fahad Al Mahmood
This program animates the movement of a billiard ball.
|
| th=theta_impact(th,width,height,x0,y0)
|
%
% This function recalculates the value of (Theta) depending on the impact
% location
%
%
function th=theta_impact(th,width,height,x0,y0)
if th>0 & th<90
if x0>=width
th=180-th;
return;
elseif y0>=height
th=360-th;
return;
end
elseif th>90 & th<180
if x0<=0
th=180-th;
return;
elseif y0>=height
th=360-th;
return;
end
elseif th>180 & th<270
if x0<=0
th=540-th;
return;
elseif y0<=0
th=360-th;
return;
end
elseif th>270 & th<360
if x0>=width
th=540-th;
return;
elseif y0<=0
th=360-th;
return;
end
elseif th==0 | th==360
th=180;
return;
elseif th==90
th=270;
return;
elseif th==180
th=0;
return;
elseif th==270
th=90;
return;
end
|
|
Contact us at files@mathworks.com