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)
| 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() |
no outgoing calls
no test coverage detected