### Question:
GridTraversal implements Spliterator<double[]> { static boolean areColinear(final double[] u, final double[] v) { double coef = Double.NaN; for (int i = 0 ; i < u.length ; i++) { double uv = v[i] - u[i]; if (!Double.isFinite(uv)) { return false; } else if (isNearZero(uv)) { continue; } else if (isNearZero(u[i])) { return false; } else if (!Double.isFinite(coef)) { coef = v[i] / u[i]; } else if (Math.abs(coef - (v[i] / u[i])) > COLINEAR_EPSILON) { return false; } } return true; } private  GridTraversal(PointList trajectory); private  GridTraversal(final PointList trajectory, final int startPoint, final int endPoint); @Override boolean tryAdvance(Consumer<? super double[]> action); @Override Spliterator<double[]> trySplit(); @Override long estimateSize(); @Override int characteristics(); static Stream<double[]> stream(final double[] trajectory, final int dimension, final boolean includeStart, final boolean parallel);  }### Answer:
@Test public void testColinearityDetection() { assertTrue(areColinear(new double[] {0, 0}, new double[]{0, 0})); assertTrue(areColinear(new double[] {0.29, 0.123, 3.2}, new double[]{0.34, 0.123, 3.2})); assertTrue(areColinear(new double[] {0.2, 1230, 345.454, 2.3}, new double[]{0.4000000002, 2460, 690.908000003, 4.6})); assertTrue(areColinear(new double[] {42, 0, 33.2}, new double[]{12600, 0, 9960})); assertFalse(areColinear(new double[] {0, 0}, new double[]{120, 10})); assertFalse(areColinear(new double[] {0, 20, 43}, new double[]{120, 10, 22})); assertFalse(areColinear(new double[] {0, 0, 12, 30}, new double[]{0, 0, 11, 10})); assertFalse(areColinear(new double[] {3.2, Double.NaN}, new double[]{3.2, 0})); assertFalse(areColinear(new double[] {Double.NaN, 0.1}, new double[]{0.1, 0.1})); }