What mathematic concept is behind this grid based pattern that I have stumbled upon rotating square grids?

Viewed 101

I was coding a grid/coordinate system for a board game and needed to rotate a standard square checkerboard cells 45deg, so they are diamonds. I found out rotating the whole board produces the same result.

Doing this, I came across a pattern for rotating square grids to get a desired amount of diamonds.

Is there a deeper mathematic concept/relationship that describes this behavior I am seeing with the grid rotation?

5 - 3 = 2 ( 1 number between 5 and 3)
7 - 4 = 3 ( 2 between )
9 - 5 = 4 ( 3 between )
11 - 6 = 5 ( 4 between )
13 - 7 = 6 ( 5...)
15 - 8 = 7 ( 6...)

[Square grid size] -  [# of diamonds] = [# of Diamonds - 1]
Or
[desired diamonds] + [desired diamonds -1] = [square grid size]
5 + 6 = 11

grid

1 Answers

User dxiv: "The small square in the top left corner (0,0),(0,6),(6,6),(6,0) has side 7, which is half the side of the big square rounded up 7 = (13+1)/2. The diagonal of the small square, which is the side of the rotated square, has as many unit squares (diamonds) as its side."

Related