baseball.frink

Download or view baseball.frink in plain text format

// Baseball calculations
//
// Alan Eliasen, eliasen@mindspring.com
//
// The rules of Major League Baseball, section 1.09 states:
// "The ball shall be a sphere formed by yarn wound around a small core of
// cork, rubber or similar material, covered with two stripes of white
// horsehide or cowhide, tightly stitched together. It shall weigh not less
// than five nor more than 5 1/4 ounces avoirdupois and measure not less than
// nine nor more than 9 1/4 inches in circumference."
//
// http://mlb.mlb.com/NASApp/mlb/mlb/baseball_basics/mlb_basics_objectives.jsp

circ = 9.25 in
mass = 5.25 oz

circ = new interval[9, 9 + 1/4] inches
mass = new interval[5, 5 + 1/4] ounces

radius[circ] := circ/(2 pi)
volume[radius] := 4/3 pi radius^3

density[mass, volume] := mass / volume

vol = volume[radius[circ]]
println["The volume is " + formatSig[vol,"in^3",5]]

dens = density[mass, vol]
println["The density is " + formatSig[dens,"g/cm^3",3]]

x[v0, alpha, h0 = 1 meter, hw = 10 feet, g=gravity] := 
{
   v0 cos[alpha] tw[v0, alpha, h0, hw, g]@1
}

// Drag force on a baseball.  See:
//
// http://farside.ph.utexas.edu/teaching/329/lectures/node42.html#fcd
// http://webusers.npl.illinois.edu/~a-nathan/pob/ppt/SABR36_June06.ppt
//
//  It's unclear what the units are of these equations, though!
//  For the 
F[v] :=
{
   vd = 35 m/s
   delta = 5 m/s
   return 0.0039 m^-1 + 0.0058 m^-1 / (1 + e^((v-vd)/delta))
}

// Reynolds number of a sphere.
// See: http://baseball.physics.illinois.edu/KensrudThesis.pdf , eq. 2.3
// viscosity is *kinematic* viscosity of air.
ReynoldsNumber[velocity is velocity, diameter is length, viscosity is kinematic_viscosity] := velocity * diameter / viscosity


/* This is the drag coefficient for a MLB baseball, non-rotating.

   See: http://baseball.physics.illinois.edu/KensrudThesis.pdf ,
   Fig. 4.37.  

   This probably needs to only go up to about 120 mph, as that
   appears to be an upper limit for batted ball exit velocity
   according to the PitchFX database:

   http://baseballsavant.com/pitchfx_search.php
*/

Cd[velocity] :=
{
   if velocity < 91.82 mph
      return -0.0033 velocity/mph + 0.5883
   else
      return -7e-5 velocity/mph + 0.2917
}
      


Download or view baseball.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 19967 days, 4 hours, 12 minutes ago.