K3D-tools / K3D-jupyter

K3D lets you create 3D plots backed by WebGL with high-level API (surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects, volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to be easy for use as stand alone package like matplotlib, but also to allow interoperation with existing libraries as VTK.
MIT License
942 stars 123 forks source link

Weird voxels behavior #321

Closed panangam closed 2 years ago

panangam commented 2 years ago

I'm trying to visualize some voxels, but neither k3d.voxels nor k3d.sparse_voxels seem to work correctly.

When using k3d.voxels on a dense grid, the orientation is wrong, and the plot is mirrored.

print(voxel_grid.shape)
k3d.voxels(voxel_grid)

Screenshot from 2021-12-21 19-49-06

When using k3d.sparse_voxels, the orientation is correct but the plot is repeated for some reason.

k3d.sparse_voxels(np.c_[voxel_coords, np.ones(voxel_coords.shape[0])], [384, 255, 12])

Screenshot from 2021-12-21 19-49-30

Here's the data: voxel_data.zip

Any idea what is going on???

artur-trzesiok commented 2 years ago

It is expected order of axis. To learn more please visit https://en.wikipedia.org/wiki/Row-_and_column-major_order

So K3D assumption is that "the fastest" axis is a x-axis.