def arclength_param(line) : "Arclength parametrisation of a piecewise affine curve." vel = line[1:, :] - line[:-1, :] vel = np.sqrt(np.sum( vel ** 2, 1 )) return np.hstack( ( [0], np.cumsum( vel, 0 ) ) )