简体   繁体   中英

What do the coordinates of verts from Marching Cubes mean?

I have a 3D generated voxel model of a vehicle and the coordinates of the voxels are in the vehicle reference frame. The origin is at the center of the floor. It looks this:

array([[-2.88783681, -0.79596956, 0.],
[-2.8752784 -0.79596956, 0.],
[-2.86271998, -0.79596956, 0.],
...,
[ 2.83880176, 0.89941685, 1.98423003],
[ 2.85136017, 0.89941685, 1.98423003],
[ 2.86391859, 0.89941685, 1.98423003]])

Then I create a meshgrid of 0s and 1s

ux = np.unique (voxels[:,0])
uy = np.unique (voxels[:,1])
uz = np. unique (voxels[:,2])

X, Y, Z = np.meshgrid(ux, uy, uz)
V = np.zeros(X. shape)
N = voxels.shape [0]
for ii in range(n):
    ix = ux == voxels[ii,]
    iy = uy == voxels[ii, 1]
    iz = uz == voxels[ii,2]
    V[iy, ix, iz] = 1

Then I call the marching cubes algorithm to generate a mesh of the voxel model.

marching_cubes = measure.marching_cubes_lewiner (v, o, spacing=(voxel_size, voxel_size, voxel_size))
verts = marching_cubes[0]
faces = marching cubes[1]
normals = marching_cubes[2]

When I print out the vertices, the coordinates are like this:

array([[2.78852894e-18, 4.39544627e-01, 3.39077284e-01),
[1.25584179-02, 4.39544627e-01, 3.26518866e-01],
[1.25584179-02, 4.26986209e-01, 3.39077284e-01],
[1.72050325e+00, 1.26840021e+00, 2.76285194-01],
[1.72050325e+00, 1.26840021e+00, 2.88843612e-01],
[1.72050325e+00, 1.26840021e+00, 3.014020302-01]])

In the documentation it says that verts is nothing but "Spatial coordinates for V unique mesh vertices". But what do the coordinates mean? In what coordinate system is it?
I plan on projecting the mesh onto the image of the vehicle I generated the voxel model from. How do I do the coordinate transformation in that case? (I've already successfully projected the voxel onto the image)

verts are just points in space. Essentially each vert is a corner of some triangle (usually more than 1).

To know what the actual triangles are you will look at faces which will have be something like:

[(v1, v2, v3), (v1, v4, v5), ...]

Each tuple in the list includes 3 indices for verts. For example:

verts[v1], verts[v2], verts[v3]

is a triangle in space.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM