0
import numpy as np
import math

length = 10

points = [(1,2,3),(1,1,1),(23, 29, 0),(17, 0, 5)]

bucketed_points = {}

max_x = max([x for (x,y,z) in points])
max_y = max([y for (x,y,z) in points])
max_z = max([z for (x,y,z) in points])

x_buckets = int(max_x)/length + 1
y_buckets = int(max_y)/length + 1
z_buckets = int(max_z)/length + 1

for x in range(0, int(x_buckets)):

  for y in range(0, int(y_buckets)):

    for z in range(0, int(z_buckets)):

      bucketed_points["{0},{1},{2}".format(x, y, z)] = []

for point in points:
 # Here's where we actually put them in buckets
  x, y, z = point
  x, y, z = map(lambda a: int(math.floor(a/length)), [x, y, z])
  bucketed_points["{0},{1},{2}".format(x, y, z)].append(point)

print(bucketed_points)

我有四个点 (1,2,3), (1,1,1),(23, 29, 0), (17, 0, 5),我需要做的就是将所有点移动到新位置(0,0,0), (0,0,0), (20,30,0), (20,0,10) 表示边长等于 10(长度 = 10)的立方体的中心点。

4

0 回答 0