Is the length of the line same in both the cases? The answer is yes, but it may look that length is different and that is due to the position of the circles.
When slightly tilted line segments are aligned horizontally like the figure, the whole array appears to tilt toward the tilt of the line elements. This is a reversal of the Zollner illusion or acute-angle contraction.