MGBaseballTrajectoryFma.html  (MotionGenesis input/output).
   (1) % MotionGenesis file:  MGBaseballTrajectoryFma.txt 
   (2) % Copyright (c) 2016 Motion Genesis LLC.  All rights reserved.
   (3) %--------------------------------------------------------------------
   (4) SetUnitSystem   lbm, ft, sec      % Set default units to US units (not SI units).
   (5) NewtonianFrame  N                 % Earth (baseball park).
   (6) Particle        Q                 % Baseball.
   (7) %--------------------------------------------------------------------
   (8) Variable   x'',  y''              % Ball's horizontal and vertical measures.
   (9) Constant   g = 32.2 ft/s^2        % Gravity (Earth = 9.8 m/s^2,  Moon = 1.7 m/s^2).
   (10) Constant   rho = 0.075 lbm/ft^3   % Density of air at sea level (1.2 kg/m^3).
   (11) Constant   r = 1.44 inches        % Ball's radius (3.66 cm).
   (12) Constant   coefDrag = 0.5 noUnits % Ball's coefficient of drag.
   (13) Q.SetMass( m = 5 ozm )
   (14) %--------------------------------------------------------------------
   (15) %      Translational kinematics (position, velocity, acceleration).
   (16) Q.Translate( No, x*Nx> + y*Ny> )
-> (17) p_No_Q> = x*Nx> + y*Ny>
-> (18) v_Q_N> = x'*Nx> + y'*Ny>
-> (19) a_Q_N> = x''*Nx> + y''*Ny>

   (20) %--------------------------------------------------------------------
   (21) %      Add relevant forces (aerodynamic and gravity).
   (22) v> = Q.GetVelocity( N )
-> (23) v> = x'*Nx> + y'*Ny>

   (24) vMag = GetMagnitude( v> )
-> (25) vMag = sqrt(x'^2+y'^2)

   (26) Area = pi*r^2    
-> (27) Area = 3.141593*r^2

   (28) DragForce> = -1/2 * rho * Area * coefDrag * vMag * v>
-> (29) DragForce> = -0.5*coefDrag*rho*Area*x'*vMag*Nx> - 0.5*coefDrag*rho*Area
        *y'*vMag*Ny>

   (30) Q.AddForce( DragForce> - m*g*Ny> )
-> (31) Force_Q> = -0.5*coefDrag*rho*Area*x'*vMag*Nx> + (-m*g-0.5*coefDrag*rho*
        Area*y'*vMag)*Ny>

   (32) %--------------------------------------------------------------------
   (33) %      Form equations of motion with F = m*a.  Solve for x'', y''.
   (34) DynamicEqn[1] = Dot( Nx>,  Q.GetDynamics() )
-> (35) DynamicEqn[1] = 0.5*coefDrag*rho*Area*x'*vMag + m*x''

   (36) DynamicEqn[2] = Dot( Ny>,  Q.GetDynamics() )
-> (37) DynamicEqn[2] = m*g + 0.5*coefDrag*rho*Area*y'*vMag + m*y''

   (38) Solve( DynamicEqn = 0,   x'',  y''  )
-> (39) x'' = -0.5*coefDrag*rho*Area*x'*vMag/m
-> (40) y'' = -g - 0.5*coefDrag*rho*Area*y'*vMag/m

   (41) %--------------------------------------------------------------------
   (42) %      Input integration parameters and initial values.
   (43) Input  tFinal = 4.6 sec,  tStep = 0.01 sec,  absError = 1.0E-7
   (44) Input  x = 0 ft,  x' = 100 * cosDegrees(30) mph
   (45) Input  y = 0 ft,  y' = 100 * sinDegrees(30) mph
   (46) %--------------------------------------------------------------------
   (47) %       List output quantities and solve ODEs.
   (48) Output  t sec,  x ft,  y ft,  x' mph,  y' mph,  vMag mph 
   (49) ODE()  MGBaseballTrajectoryFma

   (50) %--------------------------------------------------------------------
Saved by Motion Genesis LLC.   Portions copyright (c) 2009-2017 Motion Genesis LLC. Rights reserved. Only for use with MotionGenesis.