def _spline(t, p0, p1, p2, p3):
    """
    Catmull-Rom cubic spline to interpolate 4 given points.

    :param t: Time index through the spline (must be 0-1).
    :param p0: The previous point in the curve (for continuity).
    :param p1: The first point to interpolate.
    :param p2: The second point to interpolate.
    :param p3: The last point to interpolate.
    """
    return (
        t * ((2 - t) * t - 1) * p0 +
        (t * t * (3 * t - 5) + 2) * p1 +
        t * ((4 - 3 * t) * t + 1) * p2 +
        (t - 1) * t * t * p3) / 2