2D PATTERN !! HEEEELP

Hi guys, 

I have to parametrize this pattern, I will show you below the matrix and the way I have to dispose the pattern. The problem is that I have to be able to modify the distance that I highlighted in the picture. Can anyone give me an input, please ?