Well, no. ConsiderI'm not sure I follow... I need the distances proportional to each other. Is a+b not proportional to sqrt(a^2 + b^2)?
x1 = 2, z1 = 0
x2 = 1, z2 = 1
According to your code they have the same proportional distance, but in fact it is 2 and sqrt(2), respectively.