예제 #1
0
 def test_transpose(self):
     y = np.array([[1, 2, 3, 4]])
     self.assertEqual(y.shape, (1, 4))
     y = transpose(y)
     npt.assert_equal(y, np.array([[1], [2], [3], [4]]))
     y = transpose(y)
     npt.assert_equal(y, np.array([[1, 2, 3, 4]]))
예제 #2
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)
예제 #3
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)