Dad3353 ...The result is always the same, whatever the angle of the two pieces; here's a screenshot...
Here I noticed this. And here's from my experience: if you get always the same number regardless of rotation (or movement), then this number comes from the wrong system of coordinates. Totally looks like this.
Please check that you rotate the thing (change rotation angles) in that same system, where you get your transform from.
Transforming coordinates from global to local and between local systems is one of the places where it is very easy to make error.