def callable_from_trajectory(t, curves):
"""
Use scipy.interpolate splprep to build cubic b-spline interpolating
functions over a set of curves.
Parameters
----------
t : 1D array_like
Array of m time indices of trajectory
curves : 2D array_like
Array of m x n vector samples at the time indices. First dimension
indexes time, second dimension indexes vector components
Returns
-------
interpolated_callable : callable
Callable which interpolates the given curve/trajectories
"""
tck_splprep = interpolate.splprep(
x=[curves[:, i] for i in range(curves.shape[1])], u=t, s=0)
def interpolated_callable(t, *args):
return np.array(
interpolate.splev(t, tck_splprep[0], der=0)
).T.squeeze()
return interpolated_callable
评论列表
文章目录