Example #1
0
    # drawer = WindowDrawer(xlim=[-0.1, 4.0], ylim=[-0.1, 3.0], dt=dt)
    drawer = MP4Drawer(filename=name,
                       xlim=[-0.1, 4.0],
                       ylim=[-0.1, 3.0],
                       dt=dt)

    n = math.ceil((v * 2 / a) / 0.05) + 1
    xs = np.ones((n), dtype=np.float32) * nx0[0]
    ts = np.asarray(range(n), dtype=np.float32) * 0.05
    ys = -0.5 * a * ts**2 + v * ts + nx0[1]
    ncoords = np.ones((wait + len(xs), 2), dtype=np.float32) * nx0
    ncoords[wait:, 0] = xs
    ncoords[wait:, 1] = ys

    ntrace = BasicTrace(ncoords)
    nmove = TraceMove(ntrace)
    tri = Polynomics(nmove, dx)

    ts = np.asarray(range(samples), dtype=np.float32) / (samples - 1)
    ts = ts * (2.0 * math.pi)
    xs = np.cos(ts) * r + bx0[0]
    ys = np.sin(ts) * r + bx0[1]

    drawer.add_object(tri, color='b')
    drawer.draw_stable_object(xs, ys, color='r')
    drawer.draw_stable_object(*rect, color='k')

    frames = ncoords.shape[0] * 3 + wait
    drawer.start(frames=frames, interval=interval)
    nx4 = [5.2, h]
    n = math.ceil((nx4[0] - nx3[0]) / (v * 0.05 * 0.5)) + 1
    xs = np.asarray(range(n), dtype=np.float32) * (v * 0.05 * 0.5) + nx3[0]
    ys = np.ones((n), dtype=np.float32) * nx3[1]
    ncoords6 = np.asarray((xs, ys), dtype=np.float32)

    ncoords = np.concatenate([ncoords1.T, ncoords2.T, ncoords3,
                              ncoords4.T, ncoords5, ncoords6.T])

    bcoords1 = np.ones((ncoords.shape[0] - ncoords6.shape[1], 2),
                       dtype=np.float32) * xx0
    bcoords = np.concatenate([bcoords1, ncoords6.T])

    # drawer = WindowDrawer(xlim=[-0.1, 4.0], ylim=[-0.1, 3.0], dt=dt)
    drawer = MP4Drawer(filename=name, xlim=[-0.1, 4.0], ylim=[-0.1, 3.0],
                       dt=dt)

    ntrace = BasicTrace(ncoords, repeat=False)
    nmove = TraceMove(ntrace)
    tri = Polynomics(nmove, dx)

    btrace = BasicTrace(bcoords, repeat=False)
    bmove = TraceMove(btrace)
    box = Polynomics(bmove, dx2)

    drawer.add_object(tri, color='b')
    drawer.add_object(box, color='g')
    drawer.draw_stable_object(*rect, color='k')

    drawer.start(frames=ncoords.shape[0] + wait, interval=interval)