@@ -490,7 +490,7 @@ def unittwist2_norm(S):
490490
491491 return (S / th , th )
492492
493- def angdiff (a , b ):
493+ def angdiff (a , b = None ):
494494 """
495495 Angular difference
496496
@@ -501,21 +501,33 @@ def angdiff(a, b):
501501 :return: angular difference a-b
502502 :rtype: scalar or array_like
503503
504- - If ``a`` and ``b`` are both scalars, the result is scalar
505- - If ``a`` is array_like, the result is a vector a[i]-b
506- - If ``a`` is array_like, the result is a vector a-b[i]
507- - If ``a`` and ``b`` are both vectors of the same length, the result is a vector a[i]-b[i]
504+ - ``angdiff(a, b)`` is the difference ``a - b`` wrapped to the range
505+ :math:`[-\pi, \pi)`. This is the operator :math:`a \circleddash b` used
506+ in the RVC book
507+ - If ``a`` and ``b`` are both scalars, the result is scalar
508+ - If ``a`` is array_like, the result is a NumPy array ``a[i]-b``
509+ - If ``a`` is array_like, the result is a NumPy array ``a-b[i]``
510+ - If ``a`` and ``b`` are both vectors of the same length, the result is
511+ a NumPy array ``a[i]-b[i]``
512+
513+ - ``angdiff(a)`` is the angle or vector of angles ``a`` wrapped to the range
514+ :math:`[-\pi, \pi)`.
515+ - If ``a`` is a scalar, the result is scalar
516+ - If ``a`` is array_like, the result is a NumPy array
508517
509518 .. runblock:: pycon
510519
511520 >>> from spatialmath.base import *
512521 >>> from math import pi
513522 >>> angdiff(0, 2 * pi)
514523 >>> angdiff(0.9 * pi, -0.9 * pi) / pi
524+ >>> angdiff(3 * pi)
515525
516526 """
517-
518- return np .mod (a - b + math .pi , 2 * math .pi ) - math .pi
527+ if b is None :
528+ return np .mod (a + math .pi , 2 * math .pi ) - math .pi
529+ else :
530+ return np .mod (a - b + math .pi , 2 * math .pi ) - math .pi
519531
520532def removesmall (v , tol = 100 ):
521533 """
0 commit comments