(self)
| 58 | |
| 59 | class Test_Point_Ray_Distance(unittest.TestCase): |
| 60 | def test_1(self): |
| 61 | N = 5 |
| 62 | points = torch.randn(N, 3) |
| 63 | ray_origins = torch.zeros(1, 3) |
| 64 | ray_directions = torch.zeros(1, 3) |
| 65 | ray_directions[0, 2] = 1. |
| 66 | |
| 67 | out_dict = utils.compute_point_ray_distance( |
| 68 | points=points, |
| 69 | ray_origins=ray_origins, |
| 70 | ray_directions=ray_directions, |
| 71 | ) |
| 72 | dists = out_dict['dists'] |
| 73 | projections = out_dict['projections'] |
| 74 | ts = out_dict['ts'] |
| 75 | |
| 76 | assert dists.shape == (1, N) |
| 77 | assert projections.shape == (1, N, 3) |
| 78 | assert ts.shape == (1, N) |
| 79 | assert torch.allclose(dists, torch.linalg.norm(points[None, :, :2], dim=-1)) |
| 80 | assert torch.allclose(ts.sign(), points[:, 2:3].t().sign()) |
| 81 | |
| 82 | projs = torch.zeros(N, 3) |
| 83 | projs[..., 2] = points[:, 2] |
| 84 | projs = projs.unsqueeze(0) |
| 85 | assert torch.allclose(projections, projs) |
| 86 | |
| 87 | def test_chunk(self): |
| 88 | b_shape = [3, 5] |
nothing calls this directly
no outgoing calls
no test coverage detected