You are trying to implement this math function:
F(x, y) = (W1 * |x| + W2 * |y|) / (|x| + |y|)
This function is discontinuous at x = 0, y = 0 . Unfortunately, as R. R. stated in the commentary, the gap is not removable - at the moment there is no reasonable value.
This is because the “reasonable value” changes depending on the path you take to go to x = 0, y = 0 . For example, consider the path F(0, r) from r = R1 to r = 0 (this is equivalent to having the X knob at zero and smoothly adjusting the Y knob down from R1 to 0). The value of F(x, y) will be constant at W2 , until you reach the gap.
Now consider the next F(r, 0) (keeping the Y knob at zero and smoothly adjusting the X knob to zero) - the output will be constant at W1 until you reach the gap.
Now consider the next F(r, r) (holding both knobs with the same value and adjusting them down to zero). The output here will be constant at W1 + W2 / 2 until you move on to a break.
This means that any value between W1 and W2 results as a result at x = 0, y = 0 . There is no reasonable way to choose between them. (And, in addition, always choosing 0, since the output is completely incorrect, the output is otherwise limited to the interval W1..W2 (i.e., for any path that you approach the gap, the limit F() always in this interval ), and 0 cannot even lie in this interval!)
You can "fix" the problem by slightly adjusting the function - add a constant (for example, 1.0 ) to v1 and v2 after fabs() . This will make sure that the minimum contribution of each pen cannot be zero - it is simply “close to zero” (a constant determines how close).
It may be tempting to define this constant as a "very small number", but it will simply cause diversification of the output, since the manipulators manipulate near their zero points, which is probably undesirable.