class CoordinateUtils {

    public static int findMinDepthIndex(double[] depths, double from) {
        int first = Arrays.binarySearch(depths, from);
        if (first < 0) {
            // Extract insertion point
            first = -1 - first;
            // Check at 1 cm for rounding tolerance
            if (first != 0 && (Math.floor(from * 100) - Math.floor(100 * depths[first - 1])) <= 1) {
                first--;
            }
        }
        if (first == depths.length) {
            first = -1;
        }
        return first;
    }

}