我有一个兔子点云 - 虽然可以是任何对象。
我想把较大的兔子直接放在较小的兔子身上。想想具有不同层次的俄罗斯套娃。问题是让外层完美地贴合内层。主体可能不会重叠,但耳朵会重叠。
这是我的代码:
import numpy as np
#IMPORT THE OBJECT POINT CLOUD
c= np.genfromtxt(str('rabbitsmall') + '.txt',autostrip=True)
#Determine the x centre of the original object
xmax = np.amax(c[:,0])
xmin = np.amin(c[:,0])
tx = xmin+(xmax-xmin)/4
#Determine the y centre of the original object
ymax = np.amax(c[:,1])
ymin = np.amin(c[:,1])
ty =ymin+(ymax-ymin)/4
#Determine the z centre of the original object
zmax = np.amax(c[:,2])
zmin = np.amin(c[:,2])
tz = zmin+(zmax-zmin)/2
#CREATE A LARGER VERSION OF THE OBJECT
C = np.zeros((len(c),3))
for i in range(0,len(c)):
C[i][0]= 1.2*c[i][0]
C[i][1]= 1.2*c[i][1]
C[i][2]= 1.2*c[i][2]
#Determine the x centre of the larger object
Xmax = np.amax(C[:,0])
Xmin = np.amin(C[:,0])
TX = Xmin+(Xmax-Xmin)/4
#Determine the y centre of the larger object
Ymax = np.amax(C[:,1])
Ymin = np.amin(C[:,1])
TY =Ymin+(Ymax-Ymin)/4
#Determine the z centre of the larger object
Zmax = np.amax(C[:,2])
Zmin = np.amin(C[:,2])
TZ = Zmin+(Zmax-Zmin)/2
#TRANSLATE THE LARGER OBJECT TO BE OVER THE SMALLER OBJECT. IE THE CENTRES ARE AT THE SAME PLACE
for i in range(0,len(c)):
C[i][0]= C[i][0]-(TX-tx)
C[i][1]= C[i][1]-(TY-ty)
C[i][2]= C[i][2]-(TZ-tz)
np.savetxt('rabbitlarger.txt',C)