Exemplo n.º 1
0
def hermite(x0, x1, v0, v1, t):
    a = array([1, t, t**2, t**3])
    M = array([[1, 0, 0, 0],
               [1, 1, 1, 1],
               [0, 1, 0, 0],
               [0, 1, 2, 3]])
    p = transpose([[x0, x1, v0, v1]])

    return dot(dot(a, inverse(M)), p)
Exemplo n.º 2
0
def bezier2(x0, p1, p2, x1, t):
    a = array([1, t, t**2, t**3])
    M = array([[1, 0, 0, 0],
               [1, 1, 1, 1],
               [0, 1, 0, 0],
               [0, 1, 2, 3]])
    B = array([[1, 0, 0, 0],
               [0, 0, 0, 1],
               [-3, 3, 0, 0],
               [0, 0, -3, 3]])
    p = transpose([[x0, p1, p2, x1]])

    C = dot(inverse(M), B)

    return dot(dot(a, C), p)
Exemplo n.º 3
0
def covariance(xs: List[float], ys: List[float]) -> float:
    assert len(xs) == len(ys), "xs and ys must have same number of elements"

    return dot(de_mean(xs), de_mean(ys)) / (len(xs) - 1)