% y = modpi(x)

%    Copyright (C) 1995-1998
%    Massachussetts Institute of Technology
%    Sea Grant AUV Laboratory
%    $Id: modpi.m,v 1.1 2000/01/10 19:08:10 rob Exp $	

function y=modpi(x)
y = rem( x + pi, 2*pi ) - pi;

ii = find( y < -pi );
if ~isempty( ii )
    y(ii) = y(ii) + 2*pi;
end
