Here is an alternative (and ‘cheaper’, more intelligent) way to get rid of the Z problem:

Because on a Plane the Object’s Z is always 0, but we subtracted 0.5 and then multiplied by 2, making the Z always -1.
When you then calculate the length, you get the square root of (x²+y²+z²),which is the square root of (x²+y²+1) and we want the square root of (x²+y²+0).