Example #1
0
def test_rotation(angle):
    # 1. set parameters
    init_pegs = np.array([[0.25, 0.35], [0.4, 0.1], [0.47, 0.29], [0.38, 0.38],
        [0.6, 0.4],  [0.4, 0.6], [0.20, 0.7],
        [0.20, 0.15], [0.05, 1.27], [0.25, 0.90], [0.03, 0.40],
        [0.58, 0.63], [0.15, 0.05], [0.31, 0.20],
        [0.64, 0.23], [0.31, 0.93], [0.03, 0.38],
        [0.30, 0.03], [0.56, 0.06], [0.13, 1.0],
        [0.38, 0.74], [0.11, 1.28], [0.17, 1.09],
        [-0.01, 1.13], [0.42, 0.49],
        [0.00, 0.88], [-0.11, 1.28], [0.45, 0.47],
        [0.12, 0.33], [-0.02, 1.31],
        [0.15, 0.69], [0.14, 0.46], # YZ
        [0.19, 0.49], [-0.23, 0.648], # YZ ADD
        [-0.15, 0.62], # [0.05, 0.60]
        ])
    init_nodes = np.array([[0.0, 0.0], [0.3, 0.5],
        [1.0, 0.5], [1.5, 0.2]])

    T = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
    init_nodes = np.dot(T, init_nodes.transpose()).transpose()

    direction = 1
    diameter = 0.1
    init_setting = (init_nodes, init_pegs, direction, diameter)

    # 2. simulate unrolling process
    trajectory = simulate_unrolling(init_nodes, init_pegs, diameter, direction)
    origins, beziers, arcs, diameters, collide_pegs = trajectory

    # 3. plot the trajectory
    fig, ax = plt.subplots()
    plot_trajectory(init_setting, trajectory, ax=ax)
    plt.show()
Example #2
0
def test_unrolling():
    # 1. set parameters
    init_pegs = np.array([[0.25, 0.38], [0.4, 0.1], [0.6, 0.4], [0.0, 0.6],
                          [0.4, 0.6], [0.2, 0.8]])
    init_nodes = np.array([[0.0, 0.0], [0.3, 0.5], [1.0, 0.5], [1.5, 0.2]])
    direction = 1
    diameter = 0.2
    init_setting = (init_nodes, init_pegs, direction, diameter)

    # 2. simulate unrolling process
    trajectory = simulate_unrolling(init_nodes, init_pegs, diameter, direction)
    origins, beziers, arcs, diameters, collide_pegs = trajectory

    # 3. plot the trajectory
    fig, ax = plt.subplots()
    plot_trajectory(init_setting, trajectory, ax=ax)
    plt.show()
Example #3
0
    angle = np.deg2rad(angle)
    T = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
    init_nodes = np.dot(T, init_nodes.transpose()).transpose()

    direction = 1
    diameter = 0.1
    init_setting = (init_nodes, init_pegs, direction, diameter)

    # 2. simulate unrolling process
    trajectory = simulate_unrolling(init_nodes, init_pegs, diameter, direction)
    origins, beziers, arcs, diameters, collide_pegs = trajectory


    # 3. plot the trajectory
    fig, ax = plt.subplots()
    plot_trajectory(init_setting, trajectory, ax=ax)
    # ax.plot(pivots[:, 0], pivots[:, 1], 'ro', markersize=2)
    plt.show()

    # 4. unrolling animation
    """
    num_pts = 400
    step = 2
    outfile = 'cases7/unrolling-0.mp4'
    # outfile = None
    film_writer_title = 'unrolling'
    unrolling_animation(init_setting, trajectory, num_pts, step, 40, outfile=outfile,
            film_writer_title=film_writer_title)
    """

    # 5. create pulling animation
Example #4
0
def pipeline_backup():
    # test_unrolling()
    # test_animation()
    # angle = float(sys.argv[1])
    # angle = np.deg2rad(angle)
    # test_rotation(angle)
    # 1. set parameters
    init_pegs = np.array([
        [0.25, 0.35],
        [0.4, 0.1],
        [0.47, 0.29],
        [0.38, 0.38],
        [0.6, 0.4],
        [0.4, 0.6],
        [0.20, 0.7],
        [0.20, 0.15],
        [0.05, 1.27],
        [0.25, 0.90],
        [0.03, 0.40],
        [0.58, 0.63],
        [0.15, 0.05],
        [0.31, 0.20],
        [0.64, 0.23],
        [0.31, 0.93],
        [0.03, 0.38],
        [0.30, 0.03],
        [0.56, 0.06],
        [0.13, 1.0],
        [0.38, 0.74],
        [0.11, 1.28],
        [0.17, 1.09],
        [-0.01, 1.13],
        [0.42, 0.49],
        [0.00, 0.88],
        [-0.11, 1.28],
        [0.45, 0.47],
        [0.12, 0.33],
        [-0.02, 1.31],
        [0.15, 0.69],
        [0.14, 0.46],  # YZ
        [0.19, 0.49],
        [-0.23, 0.648],  # YZ ADD
        [-0.15, 0.62],  # [0.05, 0.60]
    ])
    np.savetxt('pegs.txt', init_pegs, fmt='%0.8f', delimiter=' ')

    # cases 1
    # init_nodes = np.array([[0.0, 0.0], [0.3, 0.5],
    #    [1.0, 0.5], [1.5, 0.2]])
    # cases 2 different shape
    # init_nodes = np.array([[0.0, 0.0], [0.3, 0.5],
    #    [1.0, 0.1], [1.58, 0.2]])
    # cases 3 different length
    # length = 0.8 * original angle = 61
    # init_nodes = np.array([[0, 0], [0.24, 0.4], [0.736, 0.48],
    #    [1.1808, 0.3424]])
    # length = 0.6 * original angle = 62.5
    # init_nodes = np.array([[0, 0], [0.18, 0.3], [0.504, 0.42], [0.8424, 0.4032]])
    # length = 0.4 * original angle = 61
    # init_nodes = np.array([[0, 0], [0.12, 0.2], [0.304, 0.32], [0.5136, 0.3728]])
    # cases 4 different shape
    # init_nodes = np.array([[0.0, 0.0], [0.3, 0.2],
    #    [1.0, 0.1], [1.65, 0.2]])

    # cases 5 different shape
    # init_nodes = np.array([[0.0, 0.0], [0.3, 0.2],
    #    [1.0, 0.1], [1.65, 0.05]])

    # cases 6 different shape
    # init_nodes = np.array([[0.0, 0.0], [0.3, 1.0],
    #    [1.0, -0.5], [1.5, 0.2]])

    # cases 7 different shape
    init_nodes = np.array([[0.0, 0.0], [0.3, -0.5], [1.0, 1.0], [1.5, 0.2]])

    angle = 0  # 20 30 for cases 6, 0 30 for cases 7
    angle = np.deg2rad(angle)
    T = np.array([[np.cos(angle), -np.sin(angle)],
                  [np.sin(angle), np.cos(angle)]])
    init_nodes = np.dot(T, init_nodes.transpose()).transpose()

    direction = 1
    diameter = 0.1
    init_setting = (init_nodes, init_pegs, direction, diameter)

    # 2. simulate unrolling process
    trajectory = simulate_unrolling(init_nodes, init_pegs, diameter, direction)
    origins, beziers, arcs, diameters, collide_pegs = trajectory

    # 3. plot the trajectory
    fig, ax = plt.subplots()
    plot_trajectory(init_setting, trajectory, ax=ax)
    # ax.plot(pivots[:, 0], pivots[:, 1], 'ro', markersize=2)
    plt.show()

    # 4. unrolling animation
    """
    num_pts = 400
    step = 2
    outfile = 'cases7/unrolling-0.mp4'
    # outfile = None
    film_writer_title = 'unrolling'
    unrolling_animation(init_setting, trajectory, num_pts, step, 40, outfile=outfile,
            film_writer_title=film_writer_title)
    """

    # 5. create pulling animation
    # 1. cases 1
    # angle 60
    # pivots = np.array([[-0.25, -0.2], [-0.15, 0.62], [-0.23, 0.648], [-0.5, 0.4]])
    # angle 26
    # pivots = np.array([[0, -0.2], [0.03, 0.38], [0.03, 0.40], [-0.11, 1.28],
    #    [-0.25, 1.4]])
    # angle 40
    # pivots = np.array([[0, -0.4], [-0.15, 0.62], [-0.23, 0.648]])

    # 2. cases 2 same length different shape
    # angle = 0
    # pivots = np.array([[-0.25, -0.1], [0.38, 0.38], [0.19, 0.49],
    #    [-0.15, 0.62], [-0.23, 0.648]])
    # angle = 30
    # pivots = np.array([[-0.25, 0.0], [0.03, 0.38], [0.03, 0.40],
    #    [-0.15, 0.62], [-0.23, 0.648]])
    # angle = 60
    # pivots = np.array([[-0.25, -0.1], [0.13, 1.0], [0, 0.88], [-0.23, 0.648]])

    # cases 3 different length
    # angle = 61 length = 0.8
    # pivots = np.array([[-0.25, 0.0], [-0.15, 0.62], [-0.23, 0.648], [-0.3, 0.6]])
    # angle = 62.5 length = 0.6
    # pivots = np.array([[0, -0.2], [-0.15, 0.62], [-0.23, 0.648]])
    # angle = 61 length = 0.4
    # outfile=None

    # cases 4 different shape
    # angle = 30
    # pivots = np.array([[-0.2, -0.2], [0.2, 0.15], [0.31, 0.20], [0.6, 0.4]])

    # cases 5 different shape
    # angle = 30
    # pivots = np.array([[-0.2, -0.2], [0.25, 0.35], [0.15, 0.69], [-0.02, 1.31]])

    # case 6 different shape
    # angle = 20
    # pivots = np.array([[-0.5, 0], [-0.15, 0.62], [-0.01, 1.13], [0.05, 1.27],
    #    [-0.06, 1.47]])
    # angle = 30
    # pivots = None

    # case 7 different shape
    # angle = 30
    # pivots = np.array([[-0.25, 0], [0.30, 0.03], [0.4, 0.1], [0.6, 0.4]])
    # angle = 0
    """