EllipsoidOptimisationStrategy extends AbstractBinaryFunctionOp<byte[][], Vector3d, QuickEllipsoid> { void findContactPoints(final QuickEllipsoid ellipsoid, final ArrayList<double[]> contactPoints, final byte[][] pixels, final int w, final int h, final int d) { findContactPointsForGivenDirections(ellipsoid, contactPoints, ellipsoid.getAxisAlignRandomlyDistributedSurfacePoints(algorithmParameters.nVectors), pixels, w, h, d); }  @Override QuickEllipsoid calculate(byte[][] pixels, Vector3d seedPoint);  }
@Test public void testFindContactPoints() { final double[] radii = {1, 2.1, 3.1}; final double[] centre = {3,3,2}; QuickEllipsoid e = new QuickEllipsoid(radii,centre,new double[][]{{1,0,0},{0,1,0},{0,0,1}}); double [][] vectors = new double[6][3]; vectors[0][0] = 1; vectors[1][1] = 1; vectors[2][2] = 1; vectors[3][0] = -1; vectors[4][1] = -1; vectors[5][2] = -1; final byte[][] cubeImage = getCuboidImage(); double[][] expectedContact = {{3,5.1,2},{3,3,5.1},{3,0.9,2}}; final ArrayList<double[]> contactPoints = new ArrayList<>(); EllipsoidOptimisationStrategy .findContactPointsForGivenDirections(e, contactPoints, vectors, cubeImage,6,6,6); assertEquals(3, contactPoints.size()); Stream.of(0,1,2).forEach (i -> Stream.of(0,1,2).forEach( j -> assertEquals(expectedContact[i][j],contactPoints.get(i)[j],1e-12))); }