gabyx / ApproxMVBB

Fast algorithms to compute an approximation of the minimal volume oriented bounding box of a point cloud in 3D.
Mozilla Public License 2.0
441 stars 93 forks source link

Visualization of the bounding box #45

Closed XMPeng closed 2 years ago

XMPeng commented 4 years ago

Hi gabyx, great work! One more question, how to visualize the bounding box (along with the point cloud) as the Bunny with a bounding box shown on the repo's webpage?

gabyx commented 4 years ago

Look at MVBB Tests in: https://nbviewer.jupyter.org/github/gabyx/ApproxMVBB/blob/master/tests/python/PlotTestResults.ipynb

You need to set the three following numpy arrays:

K_min = ...
K_max = ....
A_IK = ...
center = np.zeros((3,));

Something like:

[-1.42661565 -3.86197932 -1.84620041] 
[ 5.34794633  0.33660258  5.23716277]
[[ 0.70869138 -0.49319411  0.50449588]
 [ 0.63834646  0.14372591 -0.75621205]
 [ 0.3004502   0.85796412  0.41668603]] 

For the points, you can load them from a text file in python and store them in points as a 3xN-numpy matrix I think.

and then use the plot code underneath:

ax = Axes3D(fig)
    if(len(points) < 10000):
        ax.scatter(points.T[0],points.T[1],points.T[2],c='b')
    else:
        ax.scatter(points.T[0][0:10000],points.T[1][0:10000],points.T[2][0:10000],c='b')

    plotCube(ax,K_min,K_max,center,A_IK) # A_IK = R_KI (rotation from I to K)
    plotAxis(ax,center,A_IK,1)
    plotAxis(ax,center,np.identity(3),0.5)
    axisEqual3D(ax)