trajectories

class pybbda.analysis.trajectories.BattedBallTrajectory(*, x0=0, y0=2.0, z0=3.0, spin=2675, spin_phi=- 18.5, drag_strength=1, magnus_strength=1, batted_ball_constants=BattedBallConstants(mass=5.125, circumference=9.125), drag_force_coefs=DragForceCoefficients(cd0=0.3008, cdspin=0.0292), lift_force_coefs=LiftForceCoefficients(cl0=0.583, cl1=2.333, cl2=1.12, tau=10000), env_parameters=EnvironmentalParameters(g_gravity=32.174, vwind=0, phiwind=0, hwind=0, relative_humidity=50, pressure_in_hg=29.92, temperature_f=70, elevation_ft=15, beta=0.0001217))[source]

Class for a batted ball trajectory. The algorithm is taken from Alan Nathan’s trajectory calculator, http://baseball.physics.illinois.edu/trajectory-calculator-new.html

cd_fun(t, vw, spin)[source]

coefficient of drag. computed as a function of t, the time, vw, the speed with respect to the wind, and spin, the spin.

Parameters
  • t – float

  • vw – float

  • spin – float

Returns

float

cl_fun(t, vw, spin)[source]

coefficient of lift. computed as a function of t, the time, vw speed with respect to the wind, and spin, the spin

Parameters
  • t – float

  • vw – float

  • spin – float

Returns

float

get_trajectory(initial_speed, launch_angle, launch_direction_angle, initial_spin, spin_angle, delta_time=0.01)[source]

computes a batted ball trajectory. speed is in miles-per-hour, angles in degrees, and spin in revolutions per minute

Parameters
  • initial_speed – float

  • launch_angle – float

  • launch_direction_angle – float

  • initial_spin – float

  • spin_angle – float

  • delta_time – float

Returns

pandas data frame

omega_fun(t, spin)[source]

angular speed.

Parameters
  • t – float

  • spin – float

Returns

float

s_fun(t, vw, spin)[source]

spin. computed as a function of t, the time, vw speed with respect to the wind, and spin, the initial spin

Parameters
  • t – float

  • vw – float

  • spin – float

Returns

float

trajectory_fun(t, trajectory_vars, spin=2500, spin_angle=0, launch_angle=0, launch_direction_angle=0)[source]

function for computing the trajectory using the 4th-order Runge-Kutta method. trajectory vars are the 3 positions and 3 velocity components of the ball. returns the derivatives of the input variables, i.e., the 3 velocity components, and the 3 acceleration components.

Parameters
  • t – float

  • trajectory_vars – tuple(float)

  • spin – float

  • spin_angle – float

  • launch_angle – float

  • launch_direction_angle – float

Returns

numpy array

class pybbda.analysis.trajectories.BattedBallConstants(*, mass=5.125, circumference=9.125)[source]
class pybbda.analysis.trajectories.DragForceCoefficients(*, cd0=0.3008, cdspin=0.0292)[source]
class pybbda.analysis.trajectories.LiftForceCoefficients(*, cl0=0.583, cl1=2.333, cl2=1.12, tau=10000)[source]
class pybbda.analysis.trajectories.EnvironmentalParameters(*, g_gravity=32.174, vwind=0, phiwind=0, hwind=0, relative_humidity=50, pressure_in_hg=29.92, temperature_f=70, elevation_ft=15, beta=0.0001217)[source]