QuickEllipsoid { public boolean contains(final double x, final double y, final double z) { final double vx = x - cx; final double vy = y - cy; final double vz = z - cz; final double[] radii = getSortedRadii(); final double maxRadius = radii[2]; if (Math.abs(vx) > maxRadius || Math.abs(vy) > maxRadius || Math.abs(vz) > maxRadius) return false; final double length = Math.sqrt(vx * vx + vy * vy + vz * vz); if (length > maxRadius) return false; if (length <= radii[0]) return true; final double[][] h = getEllipsoidTensor(); final double dot0 = vx * h[0][0] + vy * h[1][0] + vz * h[2][0]; final double dot1 = vx * h[0][1] + vy * h[1][1] + vz * h[2][1]; final double dot2 = vx * h[0][2] + vy * h[1][2] + vz * h[2][2]; final double dot = dot0 * vx + dot1 * vy + dot2 * vz; return dot <= 1; } QuickEllipsoid(final double[] radii, final double[] centroid, final double[][] eigenVectors); static double[][] transpose(final double[][] a); boolean contains(final double x, final double y, final double z); void contract(final double increment); QuickEllipsoid copy(); void dilate(final double da, final double db, final double dc); double[] getCentre(); double[] getRadii(); double[][] getRotation(); void setRotation(final double[][] rotation); double[] getSortedRadii(); double[][] getSurfacePoints(final double[][] vectors); double[][] getAxisAlignRandomlyDistributedSurfacePoints(int n); double getVolume(); void rotate(final double[][] rotation); void setCentroid(final double x, final double y, final double z);  }
@Test public void testContains() { QuickEllipsoid e = new QuickEllipsoid(new double[]{1,2,3}, new double[]{1,1,1},new double[][]{{1,0,0},{0,1,0},{0,0,1}}); assertFalse(e.contains(1,4,1)); assertTrue(e.contains(1,1,2)); }