Home > matGeom > geom2d > angleAbsDiff.m

angleAbsDiff

PURPOSE ^

ANGLEABSDIFF Absolute difference between two angles.

SYNOPSIS ^

function dif = angleAbsDiff(angle1, angle2)

DESCRIPTION ^

ANGLEABSDIFF Absolute difference between two angles.

   AD = angleAbsDiff(ANGLE1, ANGLE2)
   Computes the absolute angular difference between two angles in radians.
   The result is comprised between 0 and PI.

   Example
     A = angleAbsDiff(pi/2, pi/3)
     A = 
         0.5236   % equal to pi/6

   See also
   angles2d, angleDiff

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2011-07-27,    using Matlab 7.9.0.529 (R2009b)
 Copyright 2011 INRA - Cepia Software Platform.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function dif = angleAbsDiff(angle1, angle2)
0002 %ANGLEABSDIFF Absolute difference between two angles.
0003 %
0004 %   AD = angleAbsDiff(ANGLE1, ANGLE2)
0005 %   Computes the absolute angular difference between two angles in radians.
0006 %   The result is comprised between 0 and PI.
0007 %
0008 %   Example
0009 %     A = angleAbsDiff(pi/2, pi/3)
0010 %     A =
0011 %         0.5236   % equal to pi/6
0012 %
0013 %   See also
0014 %   angles2d, angleDiff
0015 %
0016 % ------
0017 % Author: David Legland
0018 % e-mail: david.legland@grignon.inra.fr
0019 % Created: 2011-07-27,    using Matlab 7.9.0.529 (R2009b)
0020 % Copyright 2011 INRA - Cepia Software Platform.
0021 
0022 % first, normalization
0023 angle1 = normalizeAngle(angle1);
0024 angle2 = normalizeAngle(angle2);
0025 
0026 % compute difference and normalize
0027 dif = normalizeAngle(angle1 - angle2);
0028 dif = min(dif, 2*pi - dif);

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019