Skip to main content

trajectoryTube

#132448
import { loadLeague } from "@sportsdataverse/sdvplot";
import { statcastPitchPath, trajectoryTube } from "@sportsdataverse/sdvplot/three";

await loadLeague("mlb");
// a 96.3 mph four-seamer, Yankees at Red Sox, 2024-06-15 (Baseball Savant: game 746946, at-bat 48, pitch 4)
const pitch = {
vx0: -6.245145230392043, vy0: -140.0548111003631, vz0: -4.647911601289857,
ax: 12.681580763686934, ay: 32.15363682007945, az: -12.428443024407864,
plate_x: 0.42927397039380755, plate_z: 3.546869816011372, release_pos_y: 54.12, game_year: 2024,
};
const tube = trajectoryTube(statcastPitchPath(pitch), { radius: 0.121, team: "NYY", league: "mlb" });
// in three.js: geometry.setAttribute("position", new BufferAttribute(tube.positions, 3)), and so on
tube.color;

Tags: docstring · trajectoryTube. All sdvplot examples.