Current distance methods partially rely on looping through trajectory data sets. Rewrite using xr.apply_ufunc to speed up calculations.