% ============================================================================
% GetDrag.m
% Author: Brent Dingle, Ph.D.
% Creation Date: 2020
%
% Note this function always returns a positive value for drag
% Be certain functions such as GetAcceleration apply the correct sign
% -- so it is 'against' current velocity
%
% Drag Force = (1/2)*A*C*p*v^2
% A = surface area
% C = drag coeff
% p = density of air
% v = velocity of rocket
%
% As a reference C for a car is around 0.35
%
% TODO: make all this more realistic
% ============================================================================
function drag = GetDrag (sim, rock)
  k = GetDragCoeff(sim.t, rock.height);
  drag = k * 0.6;
  
  % the below dampens out some oscillation in force calcs and thus in accel too
  if (abs(rock.vel) < 3)  % 3 is arbitrary and not accurate
    drag = 0;
  endif
  
endfunction