% MotionGenesis file: MGBaseballTrajectoryKane.txt % Copyright (c) 2016 Motion Genesis LLC. All rights reserved. %-------------------------------------------------------------------- SetUnitSystem lbm, ft, sec % Set default units to US units (not SI units). NewtonianFrame N % Earth (baseball park). Particle Q % Baseball. %-------------------------------------------------------------------- Variable x'', y'' % Ball's horizontal and vertical measures. Constant g = 32.2 ft/s^2 % Gravity (Earth = 9.8 m/s^2, Moon = 1.7 m/s^2). Constant rho = 0.075 lbm/ft^3 % Density of air at sea level (1.2 kg/m^3). Constant r = 1.44 inches % Ball's radius (3.66 cm). Constant coefDrag = 0.5 noUnits % Ball's coefficient of drag. Q.SetMass( m = 5 ozm ) SetGeneralizedSpeeds( x', y' ) %-------------------------------------------------------------------- % Translational kinematics (position, velocity, acceleration). Q.Translate( No, x*Nx> + y*Ny> ) %-------------------------------------------------------------------- % Add relevant forces (aerodynamic and gravity). v> = Q.GetVelocity( N ) vMag = GetMagnitude( v> ) Area = pi*r^2 DragForce> = -1/2 * rho * Area * coefDrag * vMag * v> Q.AddForce( DragForce> - m*g*Ny> ) %-------------------------------------------------------------------- % Form equations of motion with F = m*a. Solve for x'', y''. DynamicEqn = System.GetDynamicsKane() Solve( DynamicEqn = 0, x'', y'' ) %-------------------------------------------------------------------- % Input integration parameters and initial values. Input tFinal = 4.6 sec, tStep = 0.01 sec, absError = 1.0E-7 Input x = 0 ft, x' = 100 * cosDegrees(30) mph Input y = 0 ft, y' = 100 * sinDegrees(30) mph %-------------------------------------------------------------------- % List output quantities and solve ODEs. Output t sec, x ft, y ft, x' mph, y' mph, vMag mph ODE() MGBaseballTrajectoryKane %-------------------------------------------------------------------- Save MGBaseballTrajectoryKane.html Quit