32. A volleyball serve over the net (projectile motion) – explanation and hints
Figure 1: The motion of the ball during a volleyball serve – projectile motion
A complete explanation of projectile motion can be found on the page: Projectile motion simulation (in Serbian)
In the same place you can also try an interactive simulation of projectile motion
v0X=v0*Math.cos(alphaRad);
v0Y=v0*Math.sin(alphaRad);
where alphaRad is the value of the angle in radians.If we look only at the horizontal direction, the motion is uniform and the projection of the ball onto the horizontal direction moves at a constant speed
vX=v0X
If the distance xM of the net from the serving player is known, then using the speed in the horizontal direction v0X we can find the time tM the ball needs to reach the x coordinate of the net:
tM = xM/v0X |
(1) |
We will look at the motion of the ball in the vertical direction. From the initial height H0 the ball moves vertically upwards with the initial vertical speed v0Y (computed from v0 entered by the user) and reaches some maximum height Hmax (see the picture).
Hmax=H0 + dH |
(2) |
g = 9.81 m/s2
From the well-known formula for uniformly accelerated motions = v0*t - a*t2 / 2
if we put g instead of a, and dH instead of s, because the change of height is actually the distance travelled in the vertical direction, we get:
dH = v0Y*t - g*t2 / 2 |
(3) |
Hmax = H0 + v0Y*t - g*t2 / 2 |
(4) |
in this case we still cannot say that the ball will go over the net, because the ball does not have to reach its maximum height at the x coordinate of the net, as we assumed in task no. 19. That is why we have to find the height H the ball will have at the moment when it is at the net, i.e. at the coordinate xM, and that will happen after the time tM from the hit (equation 1).
To find this height H we add the change of height dH to the initial height, and to find dH we put into equation (3) the time we computed with formula (1)
dH = v0Y*tM - g*tM2 / 2
and further
H = H0 + v0Y*tM - g*tM2 / 2 |
(5) |
we can say that the ball will go over the net when H>HM, otherwise it will not
Finding the maximum range
We can find the range if we look at the motion in the horizontal direction with the speed v0X, which is constant, so:
D = v0X * tD
where tD is the time from the hit until the ball falls to the ground. This time can be found by adding up the time the ball needs to reach the maximum height t1, to come down to the same height from which it was hit t1 (the same time is needed) and the time the ball then needs to fall to the ground, i.e. to come down vertically by H0.tD = 2 * t1 + tP
The time t1 is the time the ball needs to reach the maximum height, i.e. to rise by dH. When it reaches the maximum height, the speed in the vertical direction is zero, so from0 = v0Y - G*t1
we get the time t1
t1 = v0Y / G
The time tP can be found if we look at the vertical motion of the ball's projection onto the Y axis from the height H0 to the ground:H0=v0Y*tP+G*tP2/2;
G*tP2/2+v0Y*tP-H0=0;
This is a quadratic equation, and to solve it we set
a=G/2
b=v0Y
c=-H0
Solving the quadratic equation for tP we get
tP=(-b+√b2-4*a*c)/(2*a);
Finally
D=v0X*(2 * v0Y/G + tP) |
(6) |
The procedure for solving the task (the algorithm)
- Define the following data: HM, xM, v0, alpha, H, HMax, dH, g, tM, v0X, v0Y, t1, tP, D, where alpha is the angle in degrees between the vector of the ball's initial speed and the x axis
- The user enters H0, v0 and HM, the angle, xM
- Set the value of g
- Find the angle in radians, alphaRad
- Find the projections of the initial speed onto the x and y axes, i.e. v0X and v0Y
- Find the time tM the ball needs to reach the net
- Find the height H at which the ball will be when it reaches the net, using formula (5)
- Using an if-else statement, decide whether the ball goes over the net or not
- Compute the maximum height of the ball with formula (4)
- Find the maximum range D
Note: An easier version of the task would ask whether the ball will go over the net assuming that the ball reaches its maximum height at the net, i.e. at its x coordinate, because then it is enough to find HMax, and finding it does not require analysing the motion in the x direction. See task no. 19 on the page Branching in a program – examples
| Previous |<Branching in a program – examples |
Next Loops in C/C++ – examples>| |

