[Python] How to interpolate position using velocity and position samples

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have a dynamic dataset of length n, which is greater than or equal to one. The dataset contains m-dimensional position and velocity values for discrete time.

    import numpy as np

    times = np.array([t1, t2, ..., tn])
    positions = np.array([[p11, p12, ..., p1m],
    [p21, p22, ..., p2m],
    ... ,
    [pn1, pn2, ..., pnm]])
    velocities = np.array([[v11, v12, ..., v1m],
    [v21, v22, ..., v2m],
    ... ,
    [vn1, vn2, ..., vnm]])


    I would like to calculate the position and velocity value for any time, including if the value is outside of the range of the dataset. I can achieve a simple linear interpolation for the velocity using,

    interp_vel = [np.interp(t, times, v) for v in velocities.T]


    Instead of applying the same method to find the position, I would like to utilize the velocity samples in my calculation.

    Continue reading...

Compartilhe esta Página