function Pb = vecProj(a, b)
% vecProj - Compute the projection of b onto a
%   
% 
%   Syntax: 
%           Pb = vecProj(a, b)
%   Arguments: 
%           a  - The vector to project on
%           b  - The vector to project
%   Returns: 
%           Pb - The projected vector
%           
%   Description:
%
%           Computes the projection of b onto a. This is
%           computed by the formula Pb = a.b / |a|^2 a
%           
%   See also:
%

%----------------------------------------------------------------------
%   Bugs:
%
%   Date created: 
%          990910
%   Author:
%          Marten Levenstam
%
%   Change history:
%
%                              +---------------------------------------+ 
%                              |     Matematik Kf/Kb 1999-2000         | 
%                              |     Copyright (c) 1999                | 
%                              |                                       | 
%                              |     Marten Levenstam                  | 
%                              |     Klas Samuelsson                   | 
%                              |     Dep. of Mathematics               | 
%                              |     Chalmers University of Technology | 
%                              |     S-412 96 Gothenburg               | 
%                              |     SWEDEN                            |     
%                              |     martenl@math.chalmers.se          |     
%                              |                                       |     
%------------------------------+---------------------------------------+
if vecIsInR2(a) & vecIsInR2(b)
  Pb = vecDot(a, b) / vecDot(a, a) * a;
else
  error('vecProj: a or b is not in R2');
end

