MGBaseballTrajectoryKane.html  (MotionGenesis input/output).
   (1) % MotionGenesis file:  MGBaseballTrajectoryKane.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) SetGeneralizedSpeeds(  x',  y' )
   (15) %--------------------------------------------------------------------
   (16) %      Translational kinematics (position, velocity, acceleration).
   (17) Q.Translate( No, x*Nx> + y*Ny> )
-> (18) p_No_Q> = x*Nx> + y*Ny>
-> (19) v_Q_N> = x'*Nx> + y'*Ny>
-> (20) a_Q_N> = x''*Nx> + y''*Ny>

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

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

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

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

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

   (33) %--------------------------------------------------------------------
   (34) %      Form equations of motion with F = m*a.  Solve for x'', y''.
   (35) DynamicEqn = System.GetDynamicsKane()
-> (36) DynamicEqn = [0.5*coefDrag*rho*Area*x'*vMag + m*x'';  m*g + 0.5*coefDrag*rho*Area*y'*vMag + m*y'']

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

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

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