def spline_interpolate(s,t,p1,p2,p3,p4):
    """Cubic hermite spline interpolation.

    Arguments:
    s -- tension parameter, usually should be calculated as (1-t)/2
    t -- time parameter between 0.0 and 1.0, representing distance along the spline from p2 to p3.
    p1,p2,p3,p4 -- Four control points necessary for interpolation.
    """

    # Cubic hermite spline, re-arranged and optimised
    t2 = t ** 2
    t3 = t ** 3
    a = s * (-t3 + 2 * t2 - t)
    b = s * (t2 - t3)
    c = b + (2 * t3 - 3 * t2 + 1)
    d = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2)

    x = a * p1[0] + c * p2[0] + d * p3[0] - b * p4[0]
    y = a * p1[1] + c * p2[1] + d * p3[1] - b * p4[1]

    return (x,y)