X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius2.git;a=blobdiff_plain;f=mgraph.c;h=23a10e352ffa69bc91f9a4c9185fd911e90dbfd1;hp=3233890a5100e87beea2cee3919bdec7ed25c994;hb=190a54bc07e4c1497938a31373543650d3f19c55;hpb=96318dec79e12d23d718139bca74f5d33cd52253 diff --git a/mgraph.c b/mgraph.c index 3233890..23a10e3 100644 --- a/mgraph.c +++ b/mgraph.c @@ -1,35 +1,26 @@ -#include "mgraph.h" +/* + * Graph topology + */ -static const unsigned dx[V6]= { 0, +1, -1, +1, -1, 0 }, - dy[V6]= { +Y1, +Y1, 0, 0, -Y1, -Y1 }; +#include "mgraph.h" +static const unsigned dx[2][V6]= {{ +1, 0, -1, -1, -1, 0 }, + { +1, +1, 0, -1, 0, +1 }}, + dy[V6]= { 0, -Y1, -Y1, 0, +Y1, +Y1 }; int edge_end2(unsigned v1, int e) { - /* The topology is equivalent to that of a square lattice with only - * half of the diagonals. Ie, the result of shearing the triangular - * lattice to make the lines of constant x vertical. This gives - * these six directions: - * - * 0 1 - * | / - * |/ - * 2--*--3 - * /| - * / | - * 4 5 - * - * This also handily makes vertical the numbering discontinuity, - * where the join happens. - */ unsigned x, y; y= (v1 & YMASK) + dy[e]; - if (y & ~YMASK) return -1; + if (y >= Y*Y1) return -1; - x= (v1 & XMASK) + dx[e]; + x= (v1 & XMASK) + dx[(v1 >> YSHIFT) & 1][e]; if (x & ~XMASK) { + //int orgy= y; y= (Y-1)*Y1 - y; x &= XMASK;; + //printf("%40s %02x -%d-> %02x (was %02x) \n", "", v1, e, x|y, x|orgy); } + return x | y; }