angularDifference.m

Calculate the difference between two angles
177 Downloads
Updated 14 May 2014

View License

The calculation of the difference between two angles a and b, i.e., subtraction on the circle, is not entirely trivial because the circle is a closed manifold. For this operation to be well defined, a "cut" must be made so that the circle is "opened". One can then require that the interval between b and a cannot cross this cut.
Example 1: a = pi/2, b=0, cut=pi. Then
a-b = pi/2
b-a = -pi/2

Example 2: a = pi/2, b=0, cut=pi/4. Then
a-b = -3*pi/2
b-a = 3*pi/2.

For many applications one is typically concerned about small deviations from 0, and in such cases the obvious cut would be pi. But sometimes the cut must be elsewhere.

Cite As

Edmund Brekke (2024). angularDifference.m (https://www.mathworks.com/matlabcentral/fileexchange/46612-angulardifference-m), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Geometric Transformation and Image Registration in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0