Applying Pythagoras Theorem in 3D