필터 지우기
필터 지우기

Animated 2D ball trajectory with images

조회 수: 5 (최근 30일)
Pranav Nag
Pranav Nag 2021년 11월 11일
댓글: Pranav Nag 2021년 11월 24일
I'm a beginner so please bear with me if this is elementary.
I have written the code to plot the trajectory of a basketball with the following input parameters:
  1. Shooter's height (Determines launch coordinates)
  2. Defender's height (Checks if the shot is blocked or not)
  3. Separation between the shooter and defender (Additional input to check if the shot is blocked)
I have created a LiveScript which works well and have migrated to AppDesigner which also works well.
My end goal is to show an image of a basketball, the hoop and two human figures (maybe just static images of NBA players)
I want to show the basketball following the predicted trajectory as an animation in 2D.
Please help me with this? Happy to provide any additional information if required.
Thanks in advance!
  댓글 수: 1
Pranav Nag
Pranav Nag 2021년 11월 24일
Could you please help me with the code for this?
I want this image of a basketball to follow the path determined by my ode45 trajectory and move towards the image of the hoop.
Thanks in advance :)

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

채택된 답변

Jon
Jon 2021년 11월 11일
You can plot a filled circle (or an approximation of one) by plotting filled polygons using the fill command.
For example to plot a red filled circle with radius of 3 centered at x=4, y=5 you could use
numPoints = 500; % use more or less to get better or worse approximation of circle
r = 3; % radius
xc = 4;
yc = 5;
theta = linspace(0,2*pi,numPoints);
x = r*cos(theta);
y = r*sin(theta);
fill(x+xc,y+yc,'r')
axis([0 10 0 10])
axis('equal')
You could do this in a loop, with a pause, and keep incrementing xc and yc
  댓글 수: 5
Pranav Nag
Pranav Nag 2021년 11월 18일
Yes, thank you for your help!
Jon
Jon 2021년 11월 18일
Excellent, good luck with your project

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by