Institut de Robòtica i Informàtica Industrial

pi2pi

PURPOSE ^

Moves an angle to the -pi,pi range.

SYNOPSIS ^

function angle=pi2pi(angle)

DESCRIPTION ^

 Moves an angle to the -pi,pi range.
 
 Ensures that the given angles are all in the -pi, pi range.

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:

SOURCE CODE ^

0001 function angle=pi2pi(angle)
0002 % Moves an angle to the -pi,pi range.
0003 %
0004 % Ensures that the given angles are all in the -pi, pi range.
0005 
0006   dp=2*pi;
0007   ang=(angle<=-dp)||(angle>=dp);
0008   angle(ang)=mod(angle(ang),dp);
0009   
0010   ang=angle>=pi;
0011   angle(ang)=angle(ang)-2*pi;
0012   
0013   ang=angle<=-pi;
0014   angle(ang)=angle(ang)+2*pi;


Institut de Robòtica i Informàtica Industrial

Generated on Fri 24-Jul-2009 12:32:50 by m2html © 2003