openvdb icon indicating copy to clipboard operation
openvdb copied to clipboard

Expose 4x4 transform matrix through python bindings

Open rfortiz opened this issue 3 years ago • 0 comments

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

rfortiz avatar Sep 05 '22 11:09 rfortiz