# How to draw the collision of two ball with Matlab?

조회 수: 32(최근 30일)
Zong Hua Chen 2016년 10월 25일
편집: xiexiezaijian 2016년 10월 25일
How to draw the collision of two ball with Matlab? I know the governing equations of the velecitys of two balls, but it seems hard to carry out.

댓글을 달려면 로그인하십시오.

### 채택된 답변

xiexiezaijian 2016년 10월 25일
편집: xiexiezaijian 2016년 10월 25일
I think using these built-in functions will help:
1. handle01 = plot([X1,X2],[Y1,Y2],'.','MarkerSize',10);% draw two points to represent two balls.
2. handle01.XData = [newX1,newX2];handle02.YData = [newY1,newY2];drawnow;% update the location
and you could plot the collision more beautiful with a little more input arguments according the matlab manual.
here is a pseudo-code:
handle01 = plot([x1,x2],[y1,y2],'.','MarkerSize',10);
for ind1 = 1:maxIteration
[x1,y1,x2,y2] = yourGoverningEquation(...);% update the location after deltaT time
handle01.XData = [x1,x2];
handle02.YData = [y1,y2];
drawnow;
end

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

Zong Hua Chen 2016년 10월 25일
The attach file (Elastic collision -Wikipedia.pdf) is the theory of collision.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Graphics Performance in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by