Wall Ball bounce Physics

1 view (last 30 days)
gracias claude
gracias claude on 31 Jan 2021
Commented: Walter Roberson on 31 Jan 2021
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 Comments
gracias claude
gracias claude on 31 Jan 2021
should I do this in a for or while loop ?
Walter Roberson
Walter Roberson on 31 Jan 2021
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.

Sign in to comment.

Answers (0)

Categories

Find more on Physics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!