openvdb
openvdb copied to clipboard
Expose 4x4 transform matrix through python bindings
The 4x4 transform matrix is not directly accessible through python bindings.
Unless I missed it in the doc, it is only accessible as a string through the .info() method, with limited decimals.
My current workaround to recover it for use in numpy/pytorch is to call indexToWorld multiple times, but it would be nice to have direct access.
offset = torch.tensor(grid.transform.indexToWorld((0, 0, 0)))
tr = torch.eye(4, dtype=torch.float64)
tr[3, :3] = offset
tr[0, :3] = torch.tensor(grid.transform.indexToWorld((1, 0, 0))) - offset
tr[1, :3] = torch.tensor(grid.transform.indexToWorld((0, 1, 0))) - offset
tr[2, :3] = torch.tensor(grid.transform.indexToWorld((0, 0, 1))) - offset