File: DESIGN

package info (click to toggle)
atom4 4.1-9
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 836 kB
  • ctags: 1,222
  • sloc: cpp: 4,451; makefile: 46; perl: 6
file content (37 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

Triangular board representation
-------------------------------

Store as an W*H array, where each position represents a vertex on the board's
triangular divisions. The odd-numbered rows are shifted half a position to the
right of the even-numbered rows, and the rows are spaced so that the resulting
vertex positions actually form equilateral triangles.

Under this arrangement, given a point (x,y) in the array, the actual location
of the vertex is (x + (y%2)/2, y). To avoid confusion, we call the former
"board coordinates" and the latter "actual coordinates".

In board coordinates, the neighbours of any given point (x,y) are:

For even y:	(x-1, y-1),	(x, y-1)
		(x-1, y),	(x+1, y)
		(x-1, y+1),	(x, y+1)

For odd y:	(x, y-1),	(x+1, y-1)
		(x-1, y),	(x+1, y)
		(x, y+1),	(x+1, y+1)

The difference matrix between these two cases is:
	[ (1,0) (1,0) ]
DM =	[ (0,0) (0,0) ]
	[ (1,0) (1,0) ]

I.e., for even y, we use the formulae given above, for odd y, we add DM to
the formulae for even y.

On every vertex in the board, there are 6 cardinal directions, corresponding
to the 6 vertices surrounding it. For convenience, we number them clockwise
starting from the vertex to the upper left. Each cardinal direction
corresponds, obviously, to each of the 6 neighbouring vertices described above.