Question 10, in the most basic code for animation on matlab please
116 CHAPTER 6 Animation 10. Two-dimensional billiards. Write a program billard.m that calculates and displays the motion of a point particle moving in two dimensions, x and y, with constant speed The x-component of the velocity is v and the y-component is vy. The velocities remain constant, so v,(1 + 1)s v,(1) and v,(t + 1)sy(1), unless there is a bounce off one of the walls at x = 0, x L, y= 0, and y = Ly. Implement the bounce condition as follows: If x(1+ 1)-0, flip the sign of v.1+ ) so that it is positive (moving to the right). If x(t + 1) > Lx, flip the sign of v,(1 + 1) so that it is negative (moving to the left). If y(1 + ) L), flip the sign of v, so that it is negative (moving down). . . Start the particle at x =xo, y=yo. vx = vo, and v.-v,o. You will need to experiment with different time steps and simulation times a. Animate the path of the particle as a circle with a trailing line. b. Set the playback speed using an animation stride, as in AnimateE11ipse.m. c. Change the program, to accept an initial speed vo and an initial angle (with respect to the x-axis). 11. Extend the previous bil- Handball (a two-dimensional billiard with gravity). 1ard.m by adding a constant acceleration due to gravity, ay =-9.8 m/s, ax = 0. Call the new program handbal1.m. The equations of motion are given by equations (6.14) through (6.20). Good values for the parameters to start your explorations are (x,y) = (0,0), (v,H5) = ( 1.123. 3.8) m/s, Tf-12 s, Nt-12000, and a stride value of 7 a. As with the billard.m program, animate the motion with a trailing line. 116 CHAPTER 6 Animation 10. Two-dimensional billiards. Write a program billard.m that calculates and displays the motion of a point particle moving in two dimensions, x and y, with constant speed The x-component of the velocity is v and the y-component is vy. The velocities remain constant, so v,(1 + 1)s v,(1) and v,(t + 1)sy(1), unless there is a bounce off one of the walls at x = 0, x L, y= 0, and y = Ly. Implement the bounce condition as follows: If x(1+ 1)-0, flip the sign of v.1+ ) so that it is positive (moving to the right). If x(t + 1) > Lx, flip the sign of v,(1 + 1) so that it is negative (moving to the left). If y(1 + ) L), flip the sign of v, so that it is negative (moving down). . . Start the particle at x =xo, y=yo. vx = vo, and v.-v,o. You will need to experiment with different time steps and simulation times a. Animate the path of the particle as a circle with a trailing line. b. Set the playback speed using an animation stride, as in AnimateE11ipse.m. c. Change the program, to accept an initial speed vo and an initial angle (with respect to the x-axis). 11. Extend the previous bil- Handball (a two-dimensional billiard with gravity). 1ard.m by adding a constant acceleration due to gravity, ay =-9.8 m/s, ax = 0. Call the new program handbal1.m. The equations of motion are given by equations (6.14) through (6.20). Good values for the parameters to start your explorations are (x,y) = (0,0), (v,H5) = ( 1.123. 3.8) m/s, Tf-12 s, Nt-12000, and a stride value of 7 a. As with the billard.m program, animate the motion with a trailing line