(String[] a)
| 33 | |
| 34 | // test |
| 35 | static public void main(String[] a) { |
| 36 | |
| 37 | { |
| 38 | int num = 1000000; |
| 39 | FloatBuffer f = ByteBuffer.allocateDirect(4 * num * 3) |
| 40 | .order(ByteOrder.nativeOrder()) |
| 41 | .asFloatBuffer(); |
| 42 | for (int i = 0; i < num; i++) { |
| 43 | f.put((float) Math.random()); |
| 44 | f.put((float) Math.random()); |
| 45 | f.put((float) Math.random()); |
| 46 | } |
| 47 | f.rewind(); |
| 48 | |
| 49 | Flann flann = new Flann(); |
| 50 | long cloud = flann.build3(f, num); |
| 51 | |
| 52 | Log.log("flann", () -> "got :" + cloud); |
| 53 | |
| 54 | Vec3 v = new Vec3(Math.random(), Math.random(), Math.random()); |
| 55 | int c = flann.closest3(cloud, (float) v.x, (float) v.y, (float) v.z); |
| 56 | |
| 57 | Log.log("flann", () -> "closest is :" + c + " to " + v + " is " + f.get(c * 3 + 0) + " " + f.get( |
| 58 | c * 3 + 1) + " " + f |
| 59 | .get(c * 3 + 2) + " " + new Vec3(3 * c, f)); |
| 60 | |
| 61 | Log.log("flann", |
| 62 | () -> "distance is " + new Vec3(3 * c, f).distance(v) + " " + new Vec3(3 * c, f).distanceSquared( |
| 63 | v)); |
| 64 | |
| 65 | LongBuffer out = ByteBuffer.allocateDirect(8 * 10) |
| 66 | .order(ByteOrder.nativeOrder()) |
| 67 | .asLongBuffer(); |
| 68 | |
| 69 | flann.closestN3(cloud, (float) v.x, (float) v.y, (float) v.z, out, 10); |
| 70 | |
| 71 | |
| 72 | flann.free3(cloud); |
| 73 | } |
| 74 | { |
| 75 | int num = 1000000; |
| 76 | FloatBuffer f = ByteBuffer.allocateDirect(4 * num * 2) |
| 77 | .order(ByteOrder.nativeOrder()) |
| 78 | .asFloatBuffer(); |
| 79 | for (int i = 0; i < num; i++) { |
| 80 | f.put((float) Math.random()); |
| 81 | f.put((float) Math.random()); |
| 82 | } |
| 83 | f.rewind(); |
| 84 | |
| 85 | Flann flann = new Flann(); |
| 86 | long cloud = flann.build2(f, num); |
| 87 | |
| 88 | Log.log("flann", () -> "got :" + cloud); |
| 89 | |
| 90 | Vec2 v = new Vec2(Math.random(), Math.random()); |
| 91 | int c = flann.closest2(cloud, (float) v.x, (float) v.y); |
| 92 |
nothing calls this directly
no test coverage detected