function dif = angleAbsDiff(angle1, angle2)
%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-2022 INRA - Cepia Software Platform

% first, normalization
angle1 = normalizeAngle(angle1);
angle2 = normalizeAngle(angle2);

% compute difference and normalize
dif = normalizeAngle(angle1 - angle2);
dif = min(dif, 2*pi - dif);

mattools
github-repos/MATLAB/mattools-matGeom/matGeom-1fd2c937064be1ee1f4fd09fbfdf96145ebe5271/matGeom/geom2d/angleAbsDiff.m
matGeom
github-repos/MATLAB/mattools-matGeom
1fd2c937064be1ee1f4fd09fbfdf96145ebe5271