| 83 | |
| 84 | |
| 85 | def offset_points(point_xyz, quarter_voxel=1, offset_only=False, bits=2): |
| 86 | c = torch.arange(1, 2 * bits, 2, device=point_xyz.device) |
| 87 | ox, oy, oz = torch.meshgrid([c, c, c], indexing='ij') |
| 88 | offset = (torch.cat([ |
| 89 | ox.reshape(-1, 1), |
| 90 | oy.reshape(-1, 1), |
| 91 | oz.reshape(-1, 1)], 1).type_as(point_xyz) - bits) / float(bits - 1) |
| 92 | if not offset_only: |
| 93 | return ( |
| 94 | point_xyz.unsqueeze(1) + offset.unsqueeze(0).type_as(point_xyz) * quarter_voxel) |
| 95 | return offset.type_as(point_xyz) * quarter_voxel # (8,3) |
| 96 | |
| 97 | |
| 98 | @torch.enable_grad() |