예제 #1
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from drawer import WindowDrawer, MP4Drawer
from region import Region
from move import StandardMove
from objects import Ball, Trace, Area


if __name__ == '__main__':
    # drawer = WindowDrawer()
    drawer = MP4Drawer()
    region = Region([[-0.8, -0.8], [-0.8, 0.8], [0.8, 0.8], [0.8, -0.8]])
    move = StandardMove([0.5, 0.5], [-0.5, 0], [0, -0.3])

    ball = Ball(move, region, 0.1)
    trace = Trace(ball)
    area = Area(move, region)

    drawer.add_object(ball)
    drawer.add_object(trace, color='b')
    drawer.add_object(area, color='g')
    drawer.start()
예제 #2
0
    interval = 20
    wait = 40
    samples = 100
    name = 'output/scene03'

    dt = interval * 0.001
    h = 0.5 * math.sqrt(3.0) * l
    dx = np.asarray([[-0.5 * l, -h], [0.5 * l, h], [1.5 * l, -h]],
                    dtype=np.float32)
    nx0 = [0.5 - 0.5 * r + l * 0.5, h]
    rect = [[0.0, 0.5 - r, 0.5 - r, 0.0, 0.0], [0.0, 0.0, 2.0, 2.0, 0.0]]
    bx0 = [max(rect[0]) * 0.8, max(rect[1]) + r]

    # 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)