MCPcopy Create free account
hub / github.com/openai/point-e / nearest_points

Method nearest_points

point_e/util/point_cloud.py:148–165  ·  view source on GitHub ↗

For each point in another set of points, compute the point in this pointcloud which is closest. :param points: an [N x 3] array of points. :param batch_size: the number of neighbor distances to compute at once. Smaller values save memory,

(self, points: np.ndarray, batch_size: int = 16384)

Source from the content-addressed store, hash-verified

146 return data
147
148 def nearest_points(self, points: np.ndarray, batch_size: int = 16384) -> np.ndarray:
149 """
150 For each point in another set of points, compute the point in this
151 pointcloud which is closest.
152
153 :param points: an [N x 3] array of points.
154 :param batch_size: the number of neighbor distances to compute at once.
155 Smaller values save memory, while larger values may
156 make the computation faster.
157 :return: an [N] array of indices into self.coords.
158 """
159 norms = np.sum(self.coords**2, axis=-1)
160 all_indices = []
161 for i in range(0, len(points), batch_size):
162 batch = points[i : i + batch_size]
163 dists = norms + np.sum(batch**2, axis=-1)[:, None] - 2 * (batch @ self.coords.T)
164 all_indices.append(np.argmin(dists, axis=-1))
165 return np.concatenate(all_indices, axis=0)
166
167 def combine(self, other: "PointCloud") -> "PointCloud":
168 assert self.channels.keys() == other.channels.keys()

Callers 2

subsampleMethod · 0.80
_nearest_vertex_channelsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected