MGProjectileMotionFma.html   (MotionGenesis input/output).
   (1) % MotionGenesis file:  MGProjectileMotionFma.txt
   (2) % Copyright (c) 2009-2020 Motion Genesis LLC.  All rights reserved.
   (3) %---------------------------------------------------------------------
   (4) NewtonianFrame  N            % Earth (baseball park).
   (5) Particle        Q            % Baseball.
   (6) %---------------------------------------------------------------------
   (7) Variable   x'',  y''         % Ball's horizontal and vertical measures.
   (8) Constant   g = 9.8 m/s^2     % Earth's gravitational acceleration.
   (9) Constant   b = 0.05 N*s/m    % Coefficient for air-resistance.
   (10) Q.SetMass( m = 145 grams )
   (11) %---------------------------------------------------------------------
   (12) %   Translational kinematics (position, velocity, acceleration).
   (13) Q.Translate( No,  x*Nx> + y*Ny> )
-> (14) p_No_Q> = x*Nx> + y*Ny>
-> (15) v_Q_N> = x'*Nx> + y'*Ny>
-> (16) a_Q_N> = x''*Nx> + y''*Ny>

   (17) %---------------------------------------------------------------------
   (18) %   Add relevant forces (aerodynamic and gravity).
   (19) Q.AddForce(  -m * g * Ny>  )
-> (20) Force_Q> = -m*g*Ny>

   (21) Q.AddForce(  -b * Q.GetVelocity(N)  )
-> (22) Force_Q> = -b*x'*Nx> + (-m*g-b*y')*Ny>

   (23) %---------------------------------------------------------------------
   (24) %   Form equations of motion with F = m*a.
   (25) DynamicsNewton[1] = Dot( Nx>,  Q.GetDynamics() )
-> (26) DynamicsNewton[1] = b*x' + m*x''

   (27) DynamicsNewton[2] = Dot( Ny>,  Q.GetDynamics() )
-> (28) DynamicsNewton[2] = m*g + b*y' + m*y''

   (29) %---------------------------------------------------------------------
   (30) %   Advanced: Verify dynamics equations with Kane's method.
   (31) SetGeneralizedSpeed( x', y' )
   (32) DynamicsKane = System.GetDynamicsKane()
-> (33) DynamicsKane = [b*x' + m*x'';  m*g + b*y' + m*y'']

   (34) isSameDynamics = IsSimplifyEqual( DynamicsNewton, DynamicsKane )
-> (35) isSameDynamics = true

   (36) %---------------------------------------------------------------------
   (37) %   Solve dynamics equations for x'' and  y''.
   (38) Solve( DynamicsNewton = 0,   x'',  y''  )
-> (39) x'' = -b*x'/m
-> (40) y'' = -g - b*y'/m

   (41) %---------------------------------------------------------------------
   (42) %   Input integration parameters and initial values.
   (43) Input  tFinal = 3.8 sec,  tStep = 0.1 sec,  absError = 1.0E-7
   (44) Input  x = 0 m,  x' = 44.7 * cosDegrees(30) m/s
   (45) Input  y = 0 m,  y' = 44.7 * sinDegrees(30) m/s
   (46) %---------------------------------------------------------------------
   (47) %   List output quantities and solve ODEs.
   (48) OutputPlot  x m,  y m
   (49) ODE()  MGProjectileMotionFma

   (50) %--------------------------------------------------------------------
Saved by Motion Genesis LLC.   Command names and syntax: Copyright (c) 2009-2021 Motion Genesis LLC. All rights reserved.