def _angle_difference()

in common/spline.py [0:0]


    def _angle_difference(y, x):
        """
        Compute the signed angle difference y - x.
        Both y and x are given as (N, 2) tensors in which the last dimension
        corresponds to [cos(angle), sin(angle)].
        """
        assert len(x.shape) == 2 and len(y.shape) == 2
        assert x.shape[-1] == 2 and y.shape[-1] == 2
        # Diff = atan2(sin(y-x), cos(y-x)), where y and x are Euler angles.
        return np.arctan2(y[:, 1]*x[:, 0] - y[:, 0]*x[:, 1], y[:, 0]*x[:, 0] + y[:, 1]*x[:, 1])