5 * Vertices in strip are numbered as follows:
8 * ___ X-2 ___ X-1 ___| 0 ___ 1 ___ 2 ___ 3 ___ 4 __
10 * / \ / \ / \ / \ / \ / \ / \
11 * / \ / \ /| \ / \ / \ / \ / \
12 * X-3 ___ X-2 ___ X-1|___ 0 ___ 1 ___ 2 ___ 3 ___ 4
13 * Y-2 Y-2 Y-2| 1 1 1 1 1
14 * \ / \ / \| / \ / \ / \ / \ /
15 * \ / \ / \ / \ / \ / \ / \ /
16 * ___ X-2 ___ X-1 ___| 0 ___ 1 ___ 2 ___ 3 __ 4 ___
18 * / \ / \ / \ / \ / \ / \ / \
19 * / \ / \ /| \ / \ / \ / \ / \
20 * X-3 ___ X-2 ___ X-1|___ 0 ___ 1 ___ 2 ___ 3 ___ 4
21 * Y-4 Y-4 Y-4| 3 3 3 3 3
23 * . . . . .| . . . . . . . . . .
25 * ___ X-2 ___ X-1 ___| 0 ___ 1 ___ 2 ___ 3 ___ 4 ___
26 * 2 2 |Y-3 Y-3 Y-3 Y-3 Y-3
27 * / \ / \ / \ / \ / \ / \ / \
28 * / \ / \ /| \ / \ / \ / \ / \
29 * __ X-2 ___ X-1|___ 0 ___ 1 ___ 2 ___ 3 ___ 3 ___ 4
30 * 1 1 | Y-2 Y-2 Y-2 Y-2 Y-2 Y-2
31 * / \ / \ / \| / \ / \ / \ / \ /
32 * / \ / \ / \ / \ / \ / \ / \ /
33 * -3 ___ X-2 ___ X-1 ___| 0 ___ 1 ___ 2 ___ 3 ___ 4 ___
34 * 0 0 0 |Y-1 Y-1 Y-1 Y-1 Y-1
37 * 0 <= x < X x = distance along
38 * 0 <= y < Y y = distance across
40 * Vertices are in reading order from diagram above ie x varies fastest.
42 * Y must be even. The actual location opposite (0,0) is (X-(Y-1)/2,0),
43 * and likewise opposite (0,Y-1) is ((Y-1)/2,0).
45 * Note that though presentation above is equilateral triangles, this
46 * is not the case. It's actually a square lattice with half of the
47 * diagonals added. We can't straighten it out because at the join
48 * the diagonals point the other way!
50 * We label edges as follows: Or in the square view:
60 * (This makes the numbering
61 * discontinuity, at the join,
62 * vertical and thus tractable.)
75 #define Y ((1<<YBITS) - 1)
77 /* vertex number: 0000 | y | x
84 #define Y1 (1 << YSHIFT)
85 #define YMASK (Y << YSHIFT)
91 #define FOR_VERTEX(v) \
92 for ((v)=0; (v)<N; (v)++)
94 #define FOR_VPEDGE(v,e) \
95 for ((e)=0; (e)<V6; (e)++)
97 extern int edge_end2(unsigned v1, int e);
98 #define EDGE_END2 edge_end2
100 #define RIM_VERTEX_P(v) (((v) & YMASK) == 0 || ((v) & YMASK) == (Y-1)*Y1)
102 #define FOR_VEDGE_X(v1,e,v2,init,otherwise) \
103 FOR_VPEDGE((v1),(e)) \
104 if (((v2)= EDGE_END2((v1),(e)), \
106 (v2)) < 0) { otherwise; } else
108 #define NOTHING ((void)0)
110 #define FOR_VEDGE(v1,e,v2) \
111 FOR_VEDGE_X(v1,e,v2,NOTHING,NOTHING)
113 #define FOR_EDGE(v1,e,v2) \
115 FOR_VEDGE((v1),(e),(v2))
117 #define FOR_RIM_VERTEX(vy,vx,v) \
118 for ((vy)=0; (vy)<Y; (vy)+=Y-1) \
119 for ((vx)=0; (v)= (vy)<<YSHIFT | (vx), (vx)<X; (vx)++)
121 typedef double Vertices[N][D3];