Java array extension/reduction
I would go with primitive Arrays, instead of using Collections and Streams in this case.
public static double[] to3D(double z, double[] in) {
    // Pre-allocated array 1.5 size of the original array
    double[] out = new double[in.length * 3 / 2];
    //loop with a step 2
    for (int i = 0, j = 0; i &lt; in.length; i += 2) {
        out[j++] = in[i];
        out[j++] = in[i + 1];
        out[j++] = z;
    }
    return out;
}

public static double[] to2D(double[] in) {
    // Pre-allocated array 2/3 size of the original array
    double[] out = new double[in.length * 2 / 3];
    //loop with a step 3
    for (int i = 0, j = 0; i &lt; in.length; i += 3) {
        out[j++] = in[i];
        out[j++] = in[i + 1];
    }
    return out;
}

Reasons for using arrays instead of lists: Input and output both are arrays, the target size is known, we only need basic operations and they would be faster in this case.
I hope it helps.