### Question:
VectorPair implements Serializable { public void omitColinearPoints(final double xTolerance, double yTolerance) { final int length = length(); final double ratio = yTolerance / xTolerance; if (!Double.isNaN(ratio)) { final Vector X = this.X; final Vector Y = this.Y; int[] indices = null; int count = 0; if (length >= 3) { yTolerance *= yTolerance; double x1 = X.doubleValue(0) * ratio; double y1 = Y.doubleValue(0); double x2 = X.doubleValue(1) * ratio; double y2 = Y.doubleValue(1); for (int i=2; i<length; i++) { double x3 = X.doubleValue(i) * ratio; double y3 = Y.doubleValue(i); final double dsq = Line2D.ptSegDistSq(x1, y1, x3, y3, x2, y2); if (dsq <= yTolerance) { if (indices == null) { indices = new int[length - 1]; while (count < i) { indices[count] = count++; } } indices[count-1] = i; } else { if (indices != null) { indices[count++] = i; } x1 = x2; y1 = y2; } x2 = x3; y2 = y3; } } if (indices != null) { indices = ArraysExt.resize(indices, count); this.X = X.pick(indices); this.Y = Y.pick(indices); } } } VectorPair(final Vector X, final Vector Y); Vector getX(); Vector getY(); int length(); void omitColinearPoints(final double xTolerance, double yTolerance); void makeStepwise(int direction);  }### Answer:
@Test public void testOmitColinearPoints() { final double[] x = {1, 2, 3, 4, 5, 6, 7, 8}; final double[] y = {4, 4, 3, 3, 3, 4, 5, 6}; final double[] ey = {4, 4, 3, 3, 6}; final double[] ex = {1, 2, 3, 5, 8}; final VectorPair pair = new VectorPair(Vector.create(x, false), Vector.create(y, false)); pair.omitColinearPoints(1E-6, 1E-6); assertEquals(Vector.create(ey, false), pair.getY()); assertEquals(Vector.create(ex, false), pair.getX()); }