Skip to content

Commit

Permalink
fix broken example code
Browse files Browse the repository at this point in the history
  • Loading branch information
lcp29 committed Feb 18, 2024
1 parent 79ba5b7 commit 009ec7b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pip install .
```
## 📖️ Example
```python
import torch
import trimesh
import matplotlib.pyplot as plt
from triro.ray.ray_optix import RayMeshIntersector
Expand All @@ -30,14 +31,14 @@ mesh = trimesh.creation.icosphere()
intersector = RayMeshIntersector(mesh)

# generating rays
x, y = torch.meshgrid([torch.linspace([-1, 1, 800]),
torch.linspace([-1, 1, 800])], indexing='ij')
y, x = torch.meshgrid([torch.linspace(1, -1, 800),
torch.linspace(-1, 1, 800)], indexing='ij')
z = -torch.ones_like(x)
ray_directions = torch.cat([x, y, z], dim=-1).cuda()
ray_directions = torch.stack([x, y, z], dim=-1).cuda()
ray_origins = torch.Tensor([0, 0, 3]).cuda().broadcast_to(ray_directions.shape)

# OptiX, Launch!
hit, front, ray_idx, tri_idx, location, uv = sr.intersects_closest(
hit, front, ray_idx, tri_idx, location, uv = intersector.intersects_closest(
ray_origins, ray_directions, stream_compaction=True
)

Expand Down

0 comments on commit 009ec7b

Please sign in to comment.