X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius2.git;a=blobdiff_plain;f=mgraph.h;h=2267fdbda1ffcf59bbf7a9919c651bee46ffa6b0;hp=08704894f7ab41841f11f44937a981f26c588a75;hb=f67c0e9702cec922ccd0d3149f48bc881b42222b;hpb=70df58c53bdd2c2b0de6a93e6c7c480730e6732a diff --git a/mgraph.h b/mgraph.h index 0870489..2267fdb 100644 --- a/mgraph.h +++ b/mgraph.h @@ -4,53 +4,64 @@ /* * Vertices in strip are numbered as follows: * - * ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 ___ 4 __ - * Y-1 Y-1 0 0 0 0 0 - * / \ / \ / \ / \ / \ / \ / \ - * / \ / \ / \ / \ / \ / \ / \ - * X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 ___ 4 - * Y-2 Y-2 Y-2 1 1 1 1 1 - * \ / \ / \ / \ / \ / \ / \ / - * \ / \ / \ / \ / \ / \ / \ / - * ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 __ - * Y-3 Y-3 Y-3 2 2 2 2 - * - * . . . . . . . . . . . . . . . - * - * X-4 ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 - * 1 1 1 1 Y-2 Y-2 Y-2 Y-2 - * \ / \ / \ / \ / \ / \ / \ / - * \ / \ / \ / \ / \ / \ / \ / - * ___ X-4 ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 __ - * 0 0 0 0 Y-1 Y-1 Y-1 + * :axis of symmetry + * | : + * | : + * ___ X-2 ___ X-1 ___| 0 ___ 1 ___ 2 ___ 3 ___ 4 __ + * Y-1 Y-1 |0: 0 0 0 0 + * / \ / \ / :\ / \ / \ / \ / \ + * / \ / \ /| : \ / \ / \ / \ / \ + * X-3 ___ X-2 ___ X-1|___ 0 ___ 1 ___ 2 ___ 3 ___ 4 + * Y-2 Y-2 Y-2| : 1 1 1 1 1 + * \ / \ / \| : / \ / \ / \ / \ / + * \ / \ / \ :/ \ / \ / \ / \ / + * ___ X-2 ___ X-1 ___| 0 ___ 1 ___ 2 ___ 3 __ 4 ___ + * Y-3 Y-3 |2: 2 2 2 2 + * / \ / \ / :\ / \ / \ / \ / \ + * / \ / \ /| : \ / \ / \ / \ / \ + * X-3 ___ X-2 ___ X-1|___ 0 ___ 1 ___ 2 ___ 3 ___ 4 + * Y-4 Y-4 Y-4| : 3 3 3 3 3 + * | : + * . . . . .| :. . . . . . . . . . + * | : + * ___ X-2 ___ X-1 ___| 0 ___ 1 ___ 2 ___ 3 ___ 4 ___ + * 2 2 |Y-3 Y-3 Y-3 Y-3 Y-3 + * / \ / \ / :\ / \ / \ / \ / \ + * / \ / \ /| : \ / \ / \ / \ / \ + * __ X-2 ___ X-1|___ 0 ___ 1 ___ 2 ___ 3 ___ 3 ___ 4 + * 1 1 | : Y-2 Y-2 Y-2 Y-2 Y-2 Y-2 + * / \ / \ / \| : / \ / \ / \ / \ / + * / \ / \ / \ :/ \ / \ / \ / \ / + * -3 ___ X-2 ___ X-1 ___| 0 ___ 1 ___ 2 ___ 3 ___ 4 ___ + * 0 0 0 |Y-1 Y-1 Y-1 Y-1 Y-1 + * | : + * | : + * | + * ^ join, where there is + * a discontinuity in numbering * * Node x,y for - * 0 <= x < X x = distance along - * 0 <= y < Y y = distance across + * 0 <= x < X = 2^XBITS x = distance along + * 0 <= y < Y = 2^YBITS-1 y = distance across * * Vertices are in reading order from diagram above ie x varies fastest. * - * Y must be even. The actual location opposite (0,0) is (X-(Y-1)/2,0), - * and likewise opposite (0,Y-1) is ((Y-1)/2,0). - * * Note that though presentation above is equilateral triangles, this * is not the case. It's actually a square lattice with half of the * diagonals added. We can't straighten it out because at the join * the diagonals point the other way! * - * We label edges as follows: Or in the square view: + * We label edges as follows: * - * \2 /1 2 1 - * \ / | / - * ___ 0 __ |/ - * 3 1 0 3--*--0 - * / \ /| - * 4/ 5\ / | - * 4 5 + * \2 /1 + * \ / + * ___ 0 __ + * 3 1 0 + * / \ + * 4/ 5\ * - * (This makes the numbering - * discontinuity, at the join, - * vertical and thus tractable.) + * vertex number: 0000 | y | x + * (YBITS) XBITS */ #ifndef MGRAPH_H @@ -58,38 +69,53 @@ #include "common.h" -#define DIMBITS 5 +#ifndef DEFSZ /* DEFSZ may be (Y/2-1)*10 + XBITS ie Y is 2*+1 */ +#define XBITS 3 +#define YBITS 3 +#define Y ((1<= 0, + * returns eprime s.t. v1==EDGE_END2(v2,eprime) */ +int edge_reverse(int v1, int e); + +#define EDGE_OPPOSITE(e) (((e)+V3) % V6) + +#define RIM_VERTEX_P(v) (((v) & ~XMASK) == 0 || ((v) & ~XMASK) == (Y-1)*Y1) #define FOR_VEDGE_X(v1,e,v2,init,otherwise) \ - FOR_VPEDGE((v1),(e)) \ + FOR_VPEDGE((e)) \ if (((v2)= EDGE_END2((v1),(e)), \ (init), \ (v2)) < 0) { otherwise; } else @@ -99,14 +125,19 @@ extern int edge_end2(unsigned v1, int e); #define FOR_VEDGE(v1,e,v2) \ FOR_VEDGE_X(v1,e,v2,NOTHING,NOTHING) -#define FOR_EDGE(v1,e,v2) \ - FOR_VERTEX((v1)) \ +#define FOR_EDGE(v1,e,v2, loop) \ + FOR_VERTEX((v1), loop) \ FOR_VEDGE((v1),(e),(v2)) -#define FOR_RIM_VERTEX(vy,vx,v) \ - for ((vy)=0; (vy)