How do get a ball bounces off the wall?

7 Ansichten (letzte 30 Tage)
chae lin lee
chae lin lee am 24 Mär. 2019
Beantwortet: Image Analyst am 24 Mär. 2019
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);

Antworten (1)

Image Analyst
Image Analyst am 24 Mär. 2019
Basically, just reflect it
yMax = 40;
if y > yMax
distanceBeyond = y - yMax;
y = yMax - distanceBeyond;
end

Kategorien

Mehr zu Graphics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by