|
17 | 17 | "metadata": {}, |
18 | 18 | "outputs": [], |
19 | 19 | "source": [ |
20 | | - "import trimesh\n", |
21 | | - "import numpy as np" |
| 20 | + "import numpy as np\n", |
| 21 | + "\n", |
| 22 | + "import trimesh" |
22 | 23 | ] |
23 | 24 | }, |
24 | 25 | { |
|
38 | 39 | "outputs": [], |
39 | 40 | "source": [ |
40 | 41 | "# create some rays\n", |
41 | | - "ray_origins = np.array([[0, 0, -3],\n", |
42 | | - " [2, 2, -3]])\n", |
43 | | - "ray_directions = np.array([[0, 0, 1],\n", |
44 | | - " [0, 0, 1]])" |
| 42 | + "ray_origins = np.array([[0, 0, -3], [2, 2, -3]])\n", |
| 43 | + "ray_directions = np.array([[0, 0, 1], [0, 0, 1]])" |
45 | 44 | ] |
46 | 45 | }, |
47 | 46 | { |
|
62 | 61 | "source": [ |
63 | 62 | "# run the mesh- ray query\n", |
64 | 63 | "locations, index_ray, index_tri = mesh.ray.intersects_location(\n", |
65 | | - " ray_origins=ray_origins,\n", |
66 | | - " ray_directions=ray_directions)" |
| 64 | + " ray_origins=ray_origins, ray_directions=ray_directions\n", |
| 65 | + ")" |
67 | 66 | ] |
68 | 67 | }, |
69 | 68 | { |
|
72 | 71 | "metadata": {}, |
73 | 72 | "outputs": [], |
74 | 73 | "source": [ |
75 | | - "# the rays hit the mesh at coordinates", "locations" |
| 74 | + "# the rays hit the mesh at coordinateslocations" |
76 | 75 | ] |
77 | 76 | }, |
78 | 77 | { |
|
81 | 80 | "metadata": {}, |
82 | 81 | "outputs": [], |
83 | 82 | "source": [ |
84 | | - "# the rays with index_ray hit the triangles stored at mesh.faces[index_tri]", |
85 | | - "len(index_ray)" |
| 83 | + "# the rays with index_ray hit the triangles stored at mesh.faces[index_tri]len(index_ray)" |
86 | 84 | ] |
87 | 85 | }, |
88 | 86 | { |
|
92 | 90 | "outputs": [], |
93 | 91 | "source": [ |
94 | 92 | "# stack rays into line segments for visualization as Path3D\n", |
95 | | - "ray_visualize = trimesh.load_path(np.hstack((ray_origins,\n", |
96 | | - " ray_origins + ray_directions*5.0)).reshape(-1, 2, 3))" |
| 93 | + "ray_visualize = trimesh.load_path(\n", |
| 94 | + " np.hstack((ray_origins, ray_origins + ray_directions * 5.0)).reshape(-1, 2, 3)\n", |
| 95 | + ")" |
97 | 96 | ] |
98 | 97 | }, |
99 | 98 | { |
|
105 | 104 | "# unmerge so viewer doesn't smooth\n", |
106 | 105 | "mesh.unmerge_vertices()\n", |
107 | 106 | "# make mesh white- ish\n", |
108 | | - "mesh.visual.face_colors = [255,255,255,255]\n", |
| 107 | + "mesh.visual.face_colors = [255, 255, 255, 255]\n", |
109 | 108 | "mesh.visual.face_colors[index_tri] = [255, 0, 0, 255]" |
110 | 109 | ] |
111 | 110 | }, |
|
116 | 115 | "outputs": [], |
117 | 116 | "source": [ |
118 | 117 | "# create a visualization scene with rays, hits, and mesh\n", |
119 | | - "scene = trimesh.Scene([mesh,\n", |
120 | | - " ray_visualize])" |
| 118 | + "scene = trimesh.Scene([mesh, ray_visualize])" |
121 | 119 | ] |
122 | 120 | }, |
123 | 121 | { |
|
0 commit comments