torchmcubes icon indicating copy to clipboard operation
torchmcubes copied to clipboard

Scale and order of verts output (how to transform to input frame)?

Open LemonPi opened this issue 2 years ago • 2 comments

My data volume consists of xyz input

            n1, n2, n3 = 80, 80, 50
            xv, yv, zv = torch.meshgrid(
                [torch.linspace(-0.2, 0.2, n1), torch.linspace(-0.2, 0.2, n2), torch.linspace(0, 0.5, n3)])

The output from marching cubes is verts, faces where

verts.min(dim=0)
tensor([ 0.7829, 28.6041, 28.3853])
verts.max(dim=0)
values=tensor([40.8141, 56.6223, 65.8527])

How can I transform verts back to the original input space? Guessing by the data ranges, verts is actually zyx data and it uses the coordinate values? Will something like (pardon the hard coding)

                verts_xyz = verts.clone()
                verts_xyz[:, 0] = verts[:, 2]
                verts_xyz[:, 2] = verts[:, 0]
                verts_xyz[:, 0] /= 80
                verts_xyz[:, 1] /= 80
                verts_xyz[:, 2] /= 50
                verts_xyz[:, 0] = verts_xyz[:, 0] * 0.4 - 0.2
                verts_xyz[:, 1] = verts_xyz[:, 1] * 0.4 - 0.2
                verts_xyz[:, 2] = verts_xyz[:, 2] * 0.5 + 0

LemonPi avatar Mar 15 '22 23:03 LemonPi