@Test public void testDistanceCalc() { final CalculateDistance calc = new ChebyshevDistance(); final double[] pos1 = {0.5, 1.0, 2.5,}; final double[] pos2 = {0.1, 2.0, -2.5,}; assertEquals(5.0, calc.calculate(pos1, pos2), 0.001); }
@Override public double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length) { double result = 0; for (int i = 0; i < length; i++) { final double d = Math.abs(position1[pos1 + i] - position2[pos2 + i]); result = Math.max(d, result); } return result; }
ChebyshevDistance extends AbstractDistance { @Override public double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length) { double result = 0; for (int i = 0; i < length; i++) { final double d = Math.abs(position1[pos1 + i] - position2[pos2 + i]); result = Math.max(d, result); } return result; } }
ChebyshevDistance extends AbstractDistance { @Override public double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length) { double result = 0; for (int i = 0; i < length; i++) { final double d = Math.abs(position1[pos1 + i] - position2[pos2 + i]); result = Math.max(d, result); } return result; }  }
ChebyshevDistance extends AbstractDistance { @Override public double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length) { double result = 0; for (int i = 0; i < length; i++) { final double d = Math.abs(position1[pos1 + i] - position2[pos2 + i]); result = Math.max(d, result); } return result; }  @Override double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length); }
ChebyshevDistance extends AbstractDistance { @Override public double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length) { double result = 0; for (int i = 0; i < length; i++) { final double d = Math.abs(position1[pos1 + i] - position2[pos2 + i]); result = Math.max(d, result); } return result; }  @Override double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length);  }