MCPcopy Create free account
hub / github.com/Yasoz/DiffTraj / resample_trajectory

Function resample_trajectory

utils/utils.py:6–23  ·  view source on GitHub ↗

Resamples a trajectory to a new length. Parameters: x (np.ndarray): original trajectory, shape (N, 2) length (int): length of resampled trajectory Returns: np.ndarray: resampled trajectory, shape (length, 2)

(x, length=200)

Source from the content-addressed store, hash-verified

4
5
6def resample_trajectory(x, length=200):
7 """
8 Resamples a trajectory to a new length.
9
10 Parameters:
11 x (np.ndarray): original trajectory, shape (N, 2)
12 length (int): length of resampled trajectory
13
14 Returns:
15 np.ndarray: resampled trajectory, shape (length, 2)
16 """
17 len_x = len(x)
18 time_steps = np.arange(length) * (len_x - 1) / (length - 1)
19 x = x.T
20 resampled_trajectory = np.zeros((2, length))
21 for i in range(2):
22 resampled_trajectory[i] = np.interp(time_steps, np.arange(len_x), x[i])
23 return resampled_trajectory.T
24
25
26def time_warping(x, length=200):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected