########################################################## # m=np.eye(3) # m[0][0]*=np.random.randint(0,2)*2-1 #ouput is either 1 or -1 # m*=scale # theta=np.random.rand()*2*math.pi # m=np.matmul(m,[[math.cos(theta),math.sin(theta),0],[-math.sin(theta),math.cos(theta),0],[0,0,1]]) # a=np.matmul(a,m)+full_scale/2+np.random.uniform(-2,2,3) # m=a.min(0) # M=a.max(0) # q=M-m # offset=-m+np.clip(full_scale-M+m-0.001,0,None)*np.random.rand(3)+np.clip(full_scale-M+m+0.001,None,0)*np.random.rand(3) ############################################################## m = np.eye(3) m *= scale a = np.matmul(a, m) + full_scale / 2 m = a.min(0) M = a.max(0) q = M - m offset = -m + np.clip(full_scale - M + m - 0.001, 0, None) + np.clip( full_scale - M + m + 0.001, None, 0) a += offset idxs = (a.min(1) >= 0) * ( a.max(1) < full_scale ) #only those points which have coords >= 0 and < full_scale are kept a = a[idxs] b = b[idxs] c = c[idxs] a = torch.from_numpy(a).long() #we do not need that, with the last columnt you can specify the sample you want to add the point to
v=np.array([list(x) for x in a.elements[0]]) #elements[0] stores all vertices with [x,y,z,r,g,b,alpha] v = v.astype(np.float32) coords=np.ascontiguousarray(v[:,:3]-v[:,:3].mean(0)) colors=np.ascontiguousarray(v[:,3:6])/127.5-1 fake_labels = np.zeros(len(coords)) #torch.save((coords,colors,w),fn[:-4]+'.pth') #saves for each vertex the coordinates, color and label locs=[] a = coords b = colors c = fake_labels m=np.eye(3) m *= scale a = np.matmul(a, m) + full_scale / 2 m = a.min(0) M = a.max(0) q = M - m offset = -m + np.clip(full_scale - M + m - 0.001, 0, None) + np.clip(full_scale - M + m + 0.001, None, 0) a+=offset idxs=(a.min(1)>=0)*(a.max(1)<full_scale) #only those points which have coords >= 0 and < full_scale are kept a=a[idxs] b=b[idxs] c=c[idxs] a=torch.from_numpy(a).long() #we do not need that, with the last columnt you can specify the sample you want to add the point to #locs = torch.cat([a,torch.LongTensor(a.shape[0],1).fill_(0)],1) #the fourth column is 0, why? locs = a #long feats = torch.from_numpy(b).float() #float labels = torch.from_numpy(c) #double