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)

4 つのポイント (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