| 217 | } |
| 218 | |
| 219 | public List<Integer> find2(Vec2 p, int n) { |
| 220 | if (cache == null || cache.capacity() < n) { |
| 221 | cache = ByteBuffer.allocateDirect(8 * n).order(ByteOrder.nativeOrder()).asLongBuffer(); |
| 222 | } |
| 223 | cache.rewind(); |
| 224 | if (cloud == -1 || !is2d) throw new IllegalArgumentException(); |
| 225 | |
| 226 | closestN2(cloud, (float) p.x, (float) p.y, cache, n); |
| 227 | |
| 228 | List<Integer> r = new ArrayList<Integer>(); |
| 229 | for (int i = 0; i < n; i++) { |
| 230 | r.add((int) cache.get(i)); |
| 231 | } |
| 232 | return r; |
| 233 | } |
| 234 | |
| 235 | public int find3(Vec3 p) { |
| 236 | |