Skip to content

Instantly share code, notes, and snippets.

@nickwan
nickwan / pitch-trajectory.py
Created September 11, 2025 03:47
Baseball Savant Pitch Trajectory a la Alan Nathan
def get_xz_at_y(row, y_target=0.0):
"""
Given a row of Baseball Savant pitch data and a target y (distance from plate),
return the (x, z) location of the pitch at that y.
Converted this via Gemini and the Alan Nathan spreadsheet
https://view.officeapps.live.com/op/view.aspx?src=https%3A%2F%2Fbaseball.physics.illinois.edu%2FTrajectoryCalculator-new-3D-May2021.xlsx&wdOrigin=BROWSELINK
If you're using pandas and numpy, you should be good to go. Sorry, I'm not good at dependencies and docs GIGGLECHAD
Parameters