# CS-3: Predict the arc of a jump

Data-Driven Athletics tutorial · Week 3 · Chapter 3 · about 60 min · workflow steps: Gather, Statistics, Visualize, Cleanse, Features

Web page: https://apopt.com/course/tutorials/cs03-jump-arc/ · Data: https://apopt.com/data/tutorials/cs03-jump-arc/

## The decision

The athlete from CS-1 jumped 16.5 cm by flight time. Should she work on takeoff speed or on her
technique in the air? Physics predicts the whole flight from the takeoff velocity alone, so the
gap between that prediction and the tracked hips says how much the posture in the air matters.
The same arc also checks the clock and the scale CS-1 had to assume.

## Predict first

By hand, before any code: a jump in the air for 0.367 s left the ground at what vertical speed, and how high above takeoff will its center of mass rise? Will the tracked hips rise more, less, or the same?

## The raw data

- `raw/jump2_keypoints_yolo26s.csv`: pose keypoints (17 joints, x and y in pixels, confidence) for all 190 frames of the course's example jump, filmed at 120 frames per second and stored at 30 Written by CS-1's pose step (YOLO26s) from `jump2_120fps.mp4`; the clip shows a person and is not published, the table shows no one.
- `raw/jump2_frame_check.csv`: the mean gray-level difference of each frame from the one before, used to flag the repeated frames Written by CS-1's Step 1 from the same clip.

| Field | Meaning | Unit | Range | Missing |
|---|---|---|---|---|
| frame | frame number in the file | count | 0–189 | never |
| <joint>_x, <joint>_y | keypoint position | pixels from the top-left; y grows downward | 0–1080, 0–1920 | none in this file |
| <joint>_c | model confidence in the keypoint | 0 to 1 | 0–1 | none |
| diff_prev | mean absolute gray-level difference from the previous frame | gray levels | 0–5 | empty for frame 0 |

What is wrong with it for this purpose: the file's clock (30 frames per second) is not the
camera's (120), and every sixth frame repeats the one before, so even the camera's clock is in
doubt; the scale comes from a stature nobody measured; the camera is hand-held and behind the
jumper, who comes closer to it in the air; and the hip midpoint is not the center of mass.

### Step 1 · Gather: the jump as a table

Once the feet leave the ground, nothing but gravity acts on the body, so its center of mass
follows a parabola set entirely by the takeoff velocity (Section 3.4.4):

x(t) = x₀ + vₓ t,  y(t) = y₀ + v_y t − ½ g t²

This study predicts that arc **before** looking at the track, lays it over the hip midpoint
frame by frame, and explains the gap. The data are the pose table of the course's example jump
from CS-1 (17 keypoints a frame, filmed at 120 frames per second, stored at 30) and CS-1's
repeated-frame check. CS-1 found takeoff at frame 80 and landing at frame 124, and a scale of
859 pixels per meter from an assumed stature of 1.70 m.

*Predict first:* The flight lasts 44 frames at 120 frames per second. What takeoff speed does that imply, in m/s?

```python
import numpy as np
import pandas as pd

kp = pd.read_csv("raw/jump2_keypoints_yolo26s.csv")
fc = pd.read_csv("raw/jump2_frame_check.csv")
FPS, G, TAKEOFF, LANDING = 120, 9.80665, 80, 124
ankle_y = kp[["l_ankle_y", "r_ankle_y"]].max(axis=1)
ear_y = (kp["l_ear_y"] + kp["r_ear_y"]) / 2
K = (ankle_y - ear_y)[:10].median() * 1.115 / 1.70           # px per m, CS-1's scale
hip = pd.DataFrame({"frame": kp["frame"],
                    "x_m": (kp["l_hip_x"] + kp["r_hip_x"]) / 2 / K,
                    "y_m": -(kp["l_hip_y"] + kp["r_hip_y"]) / 2 / K,     # minus: up is up
                    "repeat": fc["diff_prev"] < 0.5})
t_flight = (LANDING - TAKEOFF) / FPS
print(f"scale {K:.0f} px/m; flight {LANDING - TAKEOFF} frames = {t_flight:.3f} s")
print(hip.iloc[TAKEOFF - 2:TAKEOFF + 3].round(3).to_string(index=False))
```

Output:

```
scale 859 px/m; flight 44 frames = 0.367 s
 frame   x_m    y_m  repeat
    78 0.583 -1.149   False
    79 0.583 -1.149    True
    80 0.583 -1.144   False
    81 0.584 -1.122   False
    82 0.579 -1.101   False
```

### Predict first: the takeoff velocity, two ways

**From the clock.** A body that leaves and lands at the same height rises for half the flight,
so v_y = g t / 2. That needs no scale at all.

**From the last frames before takeoff.** Difference the hip positions around frame 80 (Section
3.2.1). That needs the scale, and differencing magnifies keypoint jitter (Section 3.2.4), so try
several pairs of frames and see how much the answer moves.

```python
v_clock = G * t_flight / 2
print(f"from the clock: v_y = {v_clock:.2f} m/s -> apex {100 * v_clock**2 / (2 * G):.1f} cm "
      f"at {v_clock / G:.3f} s, flight {2 * v_clock / G:.3f} s")
y = hip["y_m"].to_numpy()
for a, b in [(76, 80), (78, 82), (79, 81), (77, 83)]:
    v = (y[b] - y[a]) / ((b - a) / FPS)
    print(f"frames {a}-{b}: v_y = {v:.2f} m/s -> apex {100 * v**2 / (2 * G):5.1f} cm, flight {2 * v / G:.3f} s")
vx = (hip["x_m"][LANDING] - hip["x_m"][TAKEOFF]) / t_flight
print(f"sideways drift in the air: {vx:+.2f} m/s (the camera is behind the jumper)")
```

Output:

```
from the clock: v_y = 1.80 m/s -> apex 16.5 cm at 0.183 s, flight 0.367 s
frames 76-80: v_y = 2.16 m/s -> apex  23.8 cm, flight 0.440 s
frames 78-82: v_y = 1.44 m/s -> apex  10.5 cm, flight 0.293 s
frames 79-81: v_y = 1.64 m/s -> apex  13.8 cm, flight 0.335 s
frames 77-83: v_y = 2.30 m/s -> apex  26.9 cm, flight 0.469 s
sideways drift in the air: -0.04 m/s (the camera is behind the jumper)
```

The clock says 1.80 m/s straight up, an apex 16.5 cm above takeoff 0.183 s later. The hips give
anything from 1.4 to 2.3 m/s depending on which frames you difference: four frames span only
33 ms, and a few pixels of jitter swing the answer by a fifth. The clock's estimate is the
prediction to test. The sideways drift is small, so the arc is close to straight up.

### Step 2 · Statistics: is the scale the same in the air?

A scale measured on standing frames assumes the jumper stays the same distance from the camera.
Check it with the leg, hip to knee to ankle, whose length cannot change. Compare frames where the
leg is straight: standing at the start, and the five frames around takeoff and around landing.
(In between, the knees bend, and a bent leg seen from behind looks shorter.)

*Predict first:* If the jumper stays the same distance from the camera, how should the thigh's length in pixels change in the air?

```python
seg = {}
for name, (a, b) in {"thigh": ("hip", "knee"), "shank": ("knee", "ankle")}.items():
    seg[name] = np.hypot(kp[f"l_{a}_x"] - kp[f"l_{b}_x"], kp[f"l_{a}_y"] - kp[f"l_{b}_y"])
leg = seg["thigh"] + seg["shank"]
edges = list(range(TAKEOFF - 2, TAKEOFF + 3)) + list(range(LANDING - 2, LANDING + 3))
standing, flying = leg[:10].median(), leg[edges].median()
grow = flying / standing
print(f"straight left leg: standing {standing:.0f} px, at takeoff and landing {flying:.0f} px "
      f"({100 * (grow - 1):+.0f}%); standing again at the end {leg[-10:].median():.0f} px")
inside = hip["repeat"][TAKEOFF + 1:LANDING + 1]
print(f"frames in the air: {LANDING - TAKEOFF}; repeated frames among them: {int(inside.sum())}")
```

Output:

```
straight left leg: standing 698 px, at takeoff and landing 763 px (+9%); standing again at the end 689 px
frames in the air: 44; repeated frames among them: 7
```

The straight leg is 9% longer at takeoff and landing than standing, and back to its standing
length at the end. Bones do not grow in flight: during the jump the jumper is closer to the camera,
or the hand-held camera moved closer, so in the air every pixel stands for about 9% less distance
than the standing scale says, and heights measured there come out about 9% too large. Seven of the
44 frames in the air are repeats.

### Step 3 · Visualize: the prediction over the track

```python
import matplotlib.pyplot as plt

air = hip[(hip["frame"] >= TAKEOFF) & (hip["frame"] <= LANDING)].copy()
air["t"] = (air["frame"] - TAKEOFF) / FPS
air["track_cm"] = 100 * (air["y_m"] - y[TAKEOFF])
air["pred_cm"] = 100 * (v_clock * air["t"] - 0.5 * G * air["t"] ** 2)
air["gap_cm"] = air["track_cm"] - air["pred_cm"]
fig, ax = plt.subplots(2, 1, figsize=(6.4, 5), sharex=True, gridspec_kw={"height_ratios": [2, 1]})
ax[0].plot(air["t"], air["pred_cm"], "k-", lw=2, label=f"predicted from the clock, v = {v_clock:.2f} m/s")
new = ~air["repeat"]
ax[0].plot(air["t"][new], air["track_cm"][new], "o", ms=4, color="0.3", label="hip midpoint")
ax[0].plot(air["t"][~new], air["track_cm"][~new], "o", ms=5, mfc="white", color="0.3", label="repeated frame")
ax[0].set(ylabel="height above takeoff (cm)"); ax[0].legend(loc="lower center", fontsize=8)
ax[1].plot(air["t"], air["gap_cm"], "s-", ms=3, color="k")
ax[1].axhline(0, color="0.5", lw=1)
ax[1].set(xlabel="time since takeoff (s, 120 frames per second)", ylabel="track − prediction (cm)")
plt.tight_layout()
print(f"largest gap {air['gap_cm'].max():.1f} cm at {air.loc[air['gap_cm'].idxmax(), 't']:.3f} s; "
      f"gap at landing {air['gap_cm'].iloc[-1]:.1f} cm")
```

Output:

```
largest gap 5.9 cm at 0.167 s; gap at landing -0.4 cm
```

![Top: hip height above its takeoff height in centimeters against time since takeoff, 0 to 0.37 s; the predicted parabola from the clock rises to 16.5 cm at 0.18 s, the tracked hip midpoint (dots, repeated frames hollow) rises above it to about 22 cm. Bottom: the gap, track minus prediction, grows from 0 to about 6 cm near the top and returns toward zero at landing.](https://apopt.com/course/tutorials/cs03-jump-arc/c07-1.png)

The hips rise **above** the prediction, by up to about 6 cm near the top, and come back toward it
at landing. Section 3.4.4 expects the opposite sign from posture: arms swung up or knees tucked
lift the center of mass relative to the hips, so the hips should sag **below** the arc. A gap of
this sign points at the measurement instead: a scale 9% too small in the air (Step 2) makes the
hips' 22 cm read about 2 cm too high, and the stature behind the scale was never measured.

### Step 4 · Cleanse: one rule before the fit

A repeated frame is a copy of the frame before it, not a new measurement, so it is left out of
the fit (it is kept in the table and flagged, as in CS-1). Then fit a parabola to the flight and
read its curvature as a "gravity", g_fit = −2c₂ (Q-9). Do it on two clocks: **each file frame is
1/120 s**, the reading CS-1 used; and **only the distinct frames are 1/120 s apart**, the
reading in which the repeats were padding added to the recording, which made CS-1's jump 11.7 cm.

*Predict first:* If the padding reading were right, would g_fit come out above or below 9.81 with the right scale?

```python
fit = air[~air["repeat"] & (air["frame"] >= TAKEOFF + 2) & (air["frame"] <= LANDING - 2)]
print(f"rule: repeated frames out of the fit -> {len(fit)} of {len(air)} frames used")
distinct = np.cumsum(~hip["repeat"].to_numpy())                     # count of distinct frames so far
clocks = {"each file frame 1/120 s": fit["frame"] / FPS,
          "distinct frames 1/120 s": distinct[fit["frame"]] / FPS}
gfit = {}
for name, tt in clocks.items():
    c2, c1, c0 = np.polyfit(tt, fit["y_m"], 2)
    gfit[name] = -2 * c2
    print(f"{name}: g_fit {gfit[name]:5.1f} m/s², {gfit[name] / G:.2f} x gravity")
```

Output:

```
rule: repeated frames out of the fit -> 34 of 45 frames used
each file frame 1/120 s: g_fit  12.2 m/s², 1.24 x gravity
distinct frames 1/120 s: g_fit  17.7 m/s², 1.81 x gravity
```

### Step 5 · Features: what the curvature says about the scale and the clock

Section 10.2 gives the rule for reading a fitted gravity: g_fit / g = (k / k_used) × (f_used / f)²,
where k and f are the true scale and frame rate and k_used, f_used the ones you assumed. Two
readings of the clock and one known scale error can now be weighed against each other.

```python
for name, g in gfit.items():
    need = g / G                                  # k/k_used that would make g_fit equal gravity
    print(f"{name}: needs a scale {100 * (need - 1):+.0f}% off; "
          f"after the {100 * (grow - 1):.0f}% flight correction, {100 * (need / grow - 1):+.0f}% remains")
f_true = FPS * np.sqrt(G / gfit["each file frame 1/120 s"])
print(f"or, with the scale exactly right, the true rate would be {f_true:.0f} frames per second")
print(f"takeoff speed {v_clock:.2f} m/s: 10% faster would raise the jump to "
      f"{100 * (1.1 * v_clock) ** 2 / (2 * G):.1f} cm")
```

Output:

```
each file frame 1/120 s: needs a scale +24% off; after the 9% flight correction, +14% remains
distinct frames 1/120 s: needs a scale +81% off; after the 9% flight correction, +65% remains
or, with the scale exactly right, the true rate would be 108 frames per second
takeoff speed 1.80 m/s: 10% faster would raise the jump to 19.9 cm
```

Read the two lines together. With each file frame as 1/120 s, the arc is 24% too steep; the
flight-scale correction found in Step 2 explains 9 points of that, leaving 14% for a stature
nobody measured and a hip point that is not the center of mass. With the repeats read as padding,
the arc is 81% too steep, and no plausible scale error explains that. Put the other way: if the
scale were exact, the file's frames would be 1/108 s apart, while the padding reading needs them
1/144 s apart; the data fall on the other side of 1/120 s. So the curvature supports the
1/120 s clock, and with it CS-1's 0.367 s flight and 16.5 cm jump. Gravity checked the clock.

What limits this jump? Not the shape of the flight: once the scale doubt is set aside, the hips
follow the predicted arc to within a few centimeters. The takeoff speed is low, 1.80 m/s, and
height goes with its square, so a 10% faster takeoff would give 19.9 cm.

### Explore: takeoff speed and angle

Move the takeoff speed and angle in the viewer below and watch the apex, the flight time and the
distance change. Set a vertical takeoff at 1.80 m/s to see this jump; then tilt it forward.

### The horizontal jump

Tilt the takeoff forward and the arc becomes a standing long jump. Section 3.4.5 splits its
distance into three parts: the lean at takeoff (the center of mass is already ahead of the
toes), the flight, and the reach of the heels at landing. And the best angle is not 45°, because
a jumper pushes much harder along than straight up, so takeoff speed falls as the angle rises.
The cell uses the book's assumed numbers (lean 0.30 m, reach 0.45 m, a 0.35 m drop of the center
of mass, 3.2 m/s at 30° falling by 1.7 m/s per radian); the slope is borrowed for illustration.

```python
def long_jump(angle_deg, v30=3.2, slope=1.7, lean=0.30, reach=0.45, drop=0.35):
    a = np.radians(angle_deg)
    s = v30 - slope * (a - np.radians(30))           # assumed: speed falls as the angle rises
    vx, vy = s * np.cos(a), s * np.sin(a)
    flight = vx * (vy + np.sqrt(vy**2 + 2 * G * drop)) / G
    return lean + flight + reach, flight

angles = np.arange(5, 60.01, 0.01)
total, flight = long_jump(angles)
best = angles[np.argmax(total)]
print(f"best {best:.1f} deg: {long_jump(best)[0]:.2f} m; at 45 deg: {long_jump(45)[0]:.2f} m "
      f"({100 * (long_jump(best)[0] - long_jump(45)[0]):.0f} cm less); lean + reach = 0.75 m")
fig, ax = plt.subplots(figsize=(6.4, 3.4))
ax.plot(angles, total, "k-", lw=2, label="lean + flight + reach")
ax.plot(angles, flight, "k--", lw=1, label="flight only")
ax.axvline(best, color="0.5", lw=1)
ax.set(xlabel="takeoff angle (deg)", ylabel="distance (m)")
ax.legend(loc="lower center")
plt.tight_layout()
```

Output:

```
best 21.6 deg: 2.12 m; at 45 deg: 1.79 m (33 cm less); lean + reach = 0.75 m
```

![Jump distance in meters against takeoff angle from 5 to 60 degrees; the curve peaks at about 2.12 m near 22 degrees and falls to about 1.79 m at 45 degrees. The flight part alone is drawn dashed below it, 0.75 m lower everywhere.](https://apopt.com/course/tutorials/cs03-jump-arc/c15-1.png)

The best angle is about 22°, far below 45°, and jumping at 45° would cost about a third of a
meter. The top of the curve is flat: a few degrees either way cost a centimeter or two, while 10%
more takeoff speed is worth far more. The same lesson as the vertical jump: speed at takeoff is
the number to build.

## How good is the number?

The prediction needs only the clock: 44 frames ± 2 give a takeoff speed of 1.80 ± 0.08 m/s. Takeoff
speeds differenced from the hips spread from 1.4 to 2.3 m/s with the choice of frames, too noisy to
use. The fitted curvature is 1.24 times gravity on the 1/120 s clock and 1.81 times on the padded
clock; the 9% growth of the legs in the air explains part of the first and none of the second, so
the 1/120 s clock is the one the data support. What is left, about 14%, is the unmeasured stature
and the hips standing in for the center of mass. With one clip, one camera and no reference, none
of these can be pinned down further.

## Track it

Add `test=cmj, metric=takeoff_speed_mps, value=1.80, unit=m/s` (from g t / 2, so no scale is
needed) and `metric=arc_gfit_mps2, value=12.2, unit=m/s2` as a check of the filming setup, with the
same `protocol_version` as the CS-1 rows. A fitted gravity far from 9.8 flags the trial before its
height goes into a trend.

## With your own data

Run CS-1 on your own side-view clip to get the keypoint table and the repeat check, then put the two
files in `raw/` and change `TAKEOFF`, `LANDING`, `FPS` and the stature in the first cell.

## The same method in another field

Fitting a model whose constant is known in advance, and reading the fitted constant as a check on the
instrument, is how engineers calibrate: a pendulum's period checks a timer, a known mass checks a load
cell. The Data-Driven Engineering course's [video data](https://apmonitor.com/dde/index.php/Main/VideoData)
page turns frames into the same kind of table.

## Acknowledgements

The keypoint tables come from the course's example clip, processed locally in CS-1; no pixels are
published. The long-jump numbers are the book's assumed values (Chapter 3, Listing for Section 3.4.5).

## Action card

- **Finding:** Takeoff speed, not technique in the air, limits this jump.
- **Evidence:** The flight follows the arc predicted from a 1.80 m/s takeoff to within the scale error; a 10% faster takeoff would raise the jump from 16.5 to 19.9 cm.
- **Sure:** Moderate for the conclusion; the scale is uncertain by 10 to 20%, but the conclusion rests on the clock, which the arc's curvature confirms.
- **Action:** Train the push (faster, fuller extension at takeoff) rather than the shape in the air; film the next test from the side, phone still, so the arc can be checked without a scale doubt.
- **Retest:** Repeat the jump test in six weeks and compare takeoff speed (g t / 2) as well as height.

## Challenge: The arc of your own jump, from the side

Film three countermovement jumps from the side, phone on a tripod at waist height, at the highest
normal-speed frame rate your phone offers, with your stature measured. Run CS-1 for the keypoint
tables, then this study on each jump.

1. Predict each arc from the clock (v = g t / 2) before looking at the track.
2. Lay each prediction over the hip midpoint and plot the gap for all three jumps on one chart.
3. Check the scale in the air with the thigh and shank lengths, and fit the arc's gravity on the capture clock.
4. Say whether the gap has the same shape in all three jumps (body) or changes (noise or tracking), and its sign.

Deliverables:

- the notebook with its outputs
- one chart of the three gaps
- an action card naming takeoff speed or technique, with the evidence

## References

- *Data-Driven Athletics*, Chapter 3: Describing Motion (Section 3.2), Predicting the whole arc (Section 3.4.4) and The horizontal jump (Section 3.4.5); Chapter 10, The arc as a check on scale and frame rate (Section 10.2).

---
Text CC BY 4.0, code MIT. IRSRI Sports Research Institute.
