Wall Ball bounce Physics
    4 次查看(过去 30 天)
  
       显示 更早的评论
    
Motion of the ballI nitial position:
 x0=0, 
y0=0.
Constant Velocity: Vx= Vcosθ and Vy= Vsinθ where V and θare user inputs
.Position as function of time:x(t) = x0+ Vxty(t) = y0+ VytIn an iterative calculation:
x(t+Δt) = x(t) + VxΔt
y(t+Δt) = y(t) + VyΔt
Collision DetectionSince the box is bounded by x=10, y=10, x=-10, and y=-10, a ball will be colliding with one of the walls when x(t)≥10, x(t)≤-10, y(t)≥10, or y(t)≤-10. When a collision occurs, the ball will be bouncing off the wall.(Make sure the red dot will not go outside the box.)
7 个评论
  Walter Roberson
      
      
 2021-1-31
				What is your stopping condition?
If you are required to do a particular number of time steps then use for
If you are required to stop when a condition is reached (e.g., 20 bounces), then use a while loop.
If you are required to go indefinitely until the user interrupts with control-C then use a while loop.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


