tmp2 = xy[2 * s:size + 2 * s] - xy[s:size + s]
tmp2 = tmp2[:, ::-1]
tmp2[:, (0)] *= -1
return np.einsum('ij,ij->i', tmp1, tmp2)
Can numpy einsum() perform a cross-product between segments of a trajectory