[alogo] Spiral tiling with hexagons

Algorithm to place (tile) M regular-hexagonal tiles in a spiral-like way around the first tile, which serves as prototype for the tiling.
0) M = 1, corresponds to the prototype, placed with its gravity center at (0,0).
1) The other tiles are placed in layers around the first. Each layer contains 1*6 (the first), 2*6, 3*6, etc.
2) To find the place of the M-th tile, we determine the least integer n, such that M <= 1+3*n*(n+1).
3) This n determines the layer in which the tile is contained: n =ceiling( (sqrt( (4*M-1)/3)-1)/2).
4) Ceiling( double x ) is the function returning the smallest integer greater than x.
5) Having n, compute M1 = M-(1+3*n*(n-1)), which gives the number of tiles that precede the M-th
tile in the present layer.
6) q = M1/n and r = (M1 % n) (the quotient and rest of the division of M1 by n), determine the precise position of the tile in the layer.


[0_0] [0_1]


Every tile comes from the previous one by translating through the basic translation-vector X or
a rotation of X by some angle fi, which is multiple of pi/3.

The previous algorithm finds the place of the M-th tile, in a tiling of the plane, which proceeds in a spiral-like construction. This algorithm is used in the User-Tool script [Tiling_Spiral_Hexagon.txt].


Produced with EucliDraw©