Esempio n. 1
0
def test_mesh():
    mesh = icosphere(0.5, refinement=3)
    edge_length = float(mesh.edge_lengths().mean())
    normals = mesh.vertex_normals()
    cmesh = spatial.Mesh(mesh.vertices, mesh.vertex_normals(), mesh.faces,
                         edge_length, edge_length)
    boxes = cmesh.boxes.reshape(-1, 3, 2).transpose(0, 2, 1)
    for box in boxes[:10]:
        print(box)
Esempio n. 2
0
def test_collision():
    meshes = [icosphere(0.5, refinement=3), icosphere(0.5, [0.95, 0, 0], refinement=3)]
    lengthscale = 0.2
    grids = [spatial.Grid3d(m.vertices, lengthscale) for m in meshes]
    ctmeshes = [spatial.Mesh(
        m.vertices,
        m.vertex_normals(),
        m.faces,
        0.1, 0)
            for m in meshes
    ]

    for i, mi in enumerate(meshes):
        for j, mj in enumerate(meshes):
            print (i,j)
            info = spatial.Info(grids[i], ctmeshes[j], i == j)
            mask = info.triangle != -1
            print(info.triangle[mask])
            print(info.depth[mask])
Esempio n. 3
0
def test_collision():
    meshes = [
        icosphere(0.5, refinement=3),
        icosphere(0.5, [0.95, 0, 0], refinement=3)
    ]
    lengthscale = 0.2
    grids = [spatial.Grid3d(m.vertices, lengthscale) for m in meshes]
    ctmeshes = [
        spatial.Mesh(m.vertices, m.vertex_normals(), m.faces, 0.1, 0)
        for m in meshes
    ]

    for i, mi in enumerate(meshes):
        for j, mj in enumerate(meshes):
            print(i, j)
            info = spatial.Info(grids[i], ctmeshes[j], i == j)
            mask = info.triangle != -1
            print(info.triangle[mask])
            print(info.depth[mask])
Esempio n. 4
0
def test_mesh():
    mesh = icosphere(0.5, refinement=3)
    edge_length = float(mesh.edge_lengths().mean())
    normals = mesh.vertex_normals()
    cmesh = spatial.Mesh(
                    mesh.vertices,
                    mesh.vertex_normals(),
                    mesh.faces,
                    edge_length, edge_length)
    boxes = cmesh.boxes.reshape(-1, 3, 2).transpose(0, 2, 1)
    for box in boxes[:10]:
        print(box)
Esempio n. 5
0
        timer = app.Timer(interval=dt, connect=update)

        timer.start()
        app.run()


if __name__=='__main__':
    turtle = Mesh.load_stl('part0.stl')
    # normalize orientation
    u, s, v = np.linalg.svd(turtle.vertices, full_matrices=0)
    # v[:, [1, 2, 0]] on other machine
    turtle.vertices = turtle.vertices.dot(v) * 3 + np.array([0,0,0], np.float32)
    # turtle.faces = turtle.faces[:, ::-1]

    ico = icosphere(0.1, refinement=3)
    ball = lambda p : icosphere(0.1, p, 3)
    e = 1.5e-1
    c = 1e2
    d = .02

    grid_points = np.mgrid[0:6, 0:6, 0:40].reshape(3, -1).T * 0.05
    actors = [StaticActor(turtle),
              Balloon(ball([0,0,-0.8]), e, d, c),
              # Balloon(ball([0,0.2,-0.6]), e, d, c),
              # Balloon(ball([0,0,-0.2]), e, d, c),
              # Balloon(ball([0,0,0]), e, d, c),
              HardParticleActor(np.random.rand(1000, 3) * [2,2,5] + [[0,-0.5,-2.8]], scale=0.1)
              # FluidParticleActor(grid_points+ [[0, -0.5, -1.8]], scale=0.1)
              ]
Esempio n. 6
0
        timer = app.Timer(interval=dt, connect=update)

        timer.start()
        app.run()


if __name__ == '__main__':
    turtle = Mesh.load_stl('part0.stl')
    # normalize orientation
    u, s, v = np.linalg.svd(turtle.vertices, full_matrices=0)
    # v[:, [1, 2, 0]] on other machine
    turtle.vertices = turtle.vertices.dot(v) * 3 + np.array([0, 0, 0],
                                                            np.float32)
    # turtle.faces = turtle.faces[:, ::-1]

    ico = icosphere(0.1, refinement=3)
    ball = lambda p: icosphere(0.1, p, 3)
    e = 1.5e-1
    c = 1e2
    d = .02

    grid_points = np.mgrid[0:6, 0:6, 0:40].reshape(3, -1).T * 0.05
    actors = [
        StaticActor(turtle),
        Balloon(ball([0, 0, -0.8]), e, d, c),
        # Balloon(ball([0,0.2,-0.6]), e, d, c),
        # Balloon(ball([0,0,-0.2]), e, d, c),
        # Balloon(ball([0,0,0]), e, d, c),
        HardParticleActor(np.random.rand(1000, 3) * [2, 2, 5] +
                          [[0, -0.5, -2.8]],
                          scale=0.1)