Example #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)
Example #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])
Example #3
0
 def get_spatial_mesh(self):
     return spatial.Mesh(self.position, self.mesh.vertex_normals(),
                         np.ascontiguousarray(self.mesh.faces[:, ::+1]),
                         self.length_scale, 0)