Skip to content

Interpolation

interpolation

interpolate

interpolate(
    trajectory: Trajectory,
    timestamps: Union[list, ndarray],
    method: InterpolationMethod = LINEAR,
    inplace: bool = True,
) -> Trajectory

Interpolates a trajectory to specified timestamps using the given method.

Parameters:

  • trajectory (Trajectory) –

    Trajectory to interpolate

  • timestamps (list | ndarray) –

    Interpolation timestamps

  • method (InterpolationMethod, default: LINEAR ) –

    Interpolation method. Defaults to InterpolationMethod.LINEAR.

  • inplace (bool, default: True ) –

    Perform in-place interpolation. Defaults to True.

Returns:

  • Trajectory ( Trajectory ) –

    Interpolated trajectory

Source code in trajectopy\processing\interpolation.py
def interpolate(
    trajectory: Trajectory,
    timestamps: Union[list, np.ndarray],
    method: InterpolationMethod = InterpolationMethod.LINEAR,
    inplace: bool = True,
) -> "Trajectory":
    """Interpolates a trajectory to specified timestamps using the given method.

    Args:
        trajectory (Trajectory): Trajectory to interpolate
        timestamps (list | np.ndarray): Interpolation timestamps
        method (InterpolationMethod, optional): Interpolation method. Defaults to InterpolationMethod.LINEAR.
        inplace (bool, optional): Perform in-place interpolation. Defaults to True.

    Returns:
        Trajectory: Interpolated trajectory
    """
    if method == InterpolationMethod.LINEAR:
        return _interpolate_linear(trajectory, timestamps, inplace)
    else:
        raise ValueError(f"Interpolation method '{method}' is not supported.")