5 * Vertices in strip are numbered as follows:
7 * ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 ___ 4 __
9 * / \ / \ / \ / \ / \ / \ / \
10 * / \ / \ / \ / \ / \ / \ / \
11 * X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 ___ 4
12 * Y-2 Y-2 Y-2 1 1 1 1 1
13 * \ / \ / \ / \ / \ / \ / \ /
14 * \ / \ / \ / \ / \ / \ / \ /
15 * ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 __
18 * . . . . . . . . . . . . . . .
20 * X-4 ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3
21 * 1 1 1 1 Y-2 Y-2 Y-2 Y-2
22 * \ / \ / \ / \ / \ / \ / \ /
23 * \ / \ / \ / \ / \ / \ / \ /
24 * ___ X-4 ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 __
28 * 0 <= x < X x = distance along
29 * 0 <= y < Y y = distance across
31 * Vertices are in reading order from diagram above ie x varies fastest.
33 * Y must be even. The actual location opposite (0,0) is (X-(Y-1)/2,0),
34 * and likewise opposite (0,Y-1) is ((Y-1)/2,0).
36 * Note that though presentation above is equilateral triangles, this
37 * is not the case. It's actually a square lattice with half of the
38 * diagonals added. We can't straighten it out because at the join
39 * the diagonals point the other way!
41 * We label edges as follows: Or in the square view:
51 * (This makes the numbering
52 * discontinuity, at the join,
53 * vertical and thus tractable.)
68 /* vertex number: 0000 | y | x
75 #define Y1 (1 << YSHIFT)
76 #define YMASK ((Y-1) << YSHIFT)
82 #define FOR_VERTEX(v) \
83 for ((v)=0; (v)<N; (v)++)
85 #define FOR_VPEDGE(v,e) \
86 for ((e)=0; (e)<V6; (e)++)
88 extern int edge_end2(unsigned v1, int e);
89 #define EDGE_END2 edge_end2
91 #define FOR_VEDGE_X(v1,e,v2,init,otherwise) \
92 FOR_VPEDGE((v1),(e)) \
93 if (((v2)= EDGE_END2((v1),(e)), \
95 (v2)) < 0) { otherwise; } else
97 #define NOTHING ((void)0)
99 #define FOR_VEDGE(v1,e,v2) \
100 FOR_VEDGE_X(v1,e,v2,NOTHING,NOTHING)
102 #define FOR_EDGE(v1,e,v2) \
104 FOR_VEDGE((v1),(e),(v2))
106 #define FOR_RIM_VERTEX(vy,vx,v) \
107 for ((vy)=0; (vy)<Y; (vy)+=Y-1) \
108 for ((vx)=0; (v)= (vy)<<YSHIFT | (vx), (vx)<X; (vx)++)
110 typedef double Vertices[N][D3];