Notes | Code and Results |
---|---|
Motion without gravity.
We have a ball moving upward (in the y-direction) at 5 m/s, so its velocity vector is:
→v=<0,5,0>
Notice that:
These equations for the position comes from the fact that, as we all know, velocity is the change in distance over time. Considering only motion in the x direction (vx):
vx=ΔxΔt
We can write the change in distance (Δx) as the difference in the old and new positions:
vx=xnew−xoldΔt
Therefore, if we know the velocity (v), the time step (Δt), and the starting position (xold), then we can solve this equation to find the new position (xnew).
xnew=xold+vx⋅Δt
This could be read as: the new position is equal to the old position plus the change in position.
There is no motion in the x direction, but the same general equation applies in y, so:
|
The result should look like:
![]() |
Adding gravity (acceleration)Acceleration is the change in velocity (Δv) with time (Δt) so: a=vnew−voldΔt So for each timestep, we'll solve this equation for the new velocity (vnew ): vnew=vold+a⋅Δt The acceleration due to gravity (g) is: a=g=−9.8m/s2 So, for vertical, ballistic motion we can write the equation as: vnew=vold+g⋅Δt We can add this as a single line to the previous program, before we calculate the new position.
|
|
Add a floor
Add a floor to your model so the ball bounces.
|
![]() |