How do get a ball bounces off the wall?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How do get a ball bounces off the wall?
The ball has to bounce off the wall. Help me.
The code I made is as follows.
clc,clf,clear
v0=10;
t(1)=0;x=0;y=0;
plot(x,y,'o','MarkerFaceColor','b','MarkerSize',8)
axis([0 10 0 40])
M(1)=getframe;
dt=1/32;
open(v);
for i = 2:1000
t(i)=t(i-1)+dt;
x=t(i);
y=v0*t(i);
plot(x,y,'o','MarkerFaceColor','b','MarkerSize',8)
axis([0 10 0 40])
M(i)=getframe;
writeVideo(v,M(i));
if y>=40, break, end
end
close(v);
0 Kommentare
Antworten (1)
Image Analyst
am 24 Mär. 2019
Basically, just reflect it
yMax = 40;
if y > yMax
distanceBeyond = y - yMax;
y = yMax - distanceBeyond;
end
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!