Wall Ball bounce Physics
1 回表示 (過去 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!