function force = earthGravityAndFriction( m, r, v, b )

% Finds the force of gravity on Earth's surface, plus air friction, 
% for np particles in nd dimensions. J.M.Soler, Jan.2011.
%
% Input:
%   m(np)     : mass of the np particles, in kg
%   r(nd,np)  : position vectors of the np particles in nd dimensions, in m
%   v(nd,np)  : velocity vectors, in m/s
%   b         : wind drag coefficient, in N*s/m
% Output:
%   force(nd,np) : force vectors on the np particles, in N

% Find number of particles and dimensions
[nd,np] = size(r);

% Set gravitational force along last dimension
g = 9.80;
force = zeros(nd,np);
force(nd,:) = -m*g;

% Add friction force
force = force - b*v;

end % function earthGravityAndFriction