X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=primer.c;h=f023b10365881f25c3de3f4e7b9a23e3bc2c4586;hb=b462f455cbaa1d716ff6d7b83ae4e1092ba3092a;hp=eaa345939c93f8189ad889f5c1086ac04b8e7aef;hpb=f5fef8bc75d9d5658705763fa7c083ae75a501ba;p=moebius2.git diff --git a/primer.c b/primer.c index eaa3459..f023b10 100644 --- a/primer.c +++ b/primer.c @@ -8,20 +8,28 @@ #include "mgraph.h" int main(int argc, const char **argv) { - int v, k; + static const int prec= DBL_DIG+2; + int vi, k; if (argc>1) { fputs("no args please\n",stderr); exit(8); } printf("print %d, %d, %d, %d, %d\n", DIM, N, X, Y, D3); - FOR_VERTEX(v) { - int x= v & XMASK; /* distance along strip */ - int y= y >> YSHIFT; /* distance across strip */ - double u= y * 1.0 / (Y-1); - double v= x * M_PI / (X-1); /* SGT's u runs 0..pi along the strip */ - K printf("print %c(%.*g,%.*g)\n", - "xyz"[k], - DBL_DIG+2,u, DBL_DIG+2,v); + FOR_VERTEX(vi) { + int x= vi & XMASK; /* distance along strip */ + int y= vi >> YSHIFT; /* distance across strip */ + double u= y * 1.0 / (Y-1); /* SGT's u runs 0..1 across the strip */ + + /* SGT's v runs 0..pi along the strip, where the join is at 0==pi. + * So that corresponds to 0..X (since 0==X in our scheme). + * Vertices with odd y coordinate are halfway to the next x coordinate. + */ + double v= (x*2 + (y&1)) * M_PI / (X*2); + + K printf("print %c%c( %-*.*g, %-*.*g); # %03x %2d %2d\n", + "+-+"[k], "xyz"[k], + prec+5,prec,u, prec+5,prec,v, + vi, x, y); } flushoutput(); return 0;