class VecmathUtil {

    static Vector2d newVectorInLargestGap(final List<Vector2d> vectors) {

        assert vectors.size() > 1;
        final double[] extents = VecmathUtil.extents(vectors);
        Arrays.sort(extents);

        // find and store the index of the largest extent
        double max = -1;
        int index = -1;
        for (int i = 0; i < vectors.size(); i++) {
            double extent = extents[(i + 1) % vectors.size()] - extents[i];
            if (extent < 0) extent += TAU;
            if (extent > max) {
                max = extent;
                index = i;
            }
        }

        assert index >= 0;

        double mid = (max / 2);
        double theta = extents[index] + mid;

        return new Vector2d(Math.cos(theta), Math.sin(theta));
    }

    private  VecmathUtil();

}