chiark / gitweb /
memoise edge_end2 now performance is good
[moebius2.git] / primer.c
1 /*
2  * Generates the repetitive part of the gnuplot input
3  * for generating the initial triangle vertices from SGT's
4  * model.
5  */
6
7 #include "common.h"
8 #include "mgraph.h"
9
10 int main(int argc, const char **argv) {
11   static const int prec= DBL_DIG+2;
12   int vi;
13   
14   if (argc!=1) { fputs("need no args\n",stderr); exit(8); }
15
16   mgraph_prepare();
17
18   printf("%d %d %d %d %d\n%%-%d.%dg\n",
19          X*Y, N, X, Y, D3,
20          prec+5,prec);
21
22   FOR_VERTEX(vi, INNER) {
23     int x= vi & XMASK; /* distance along strip */
24     int y= vi >> YSHIFT; /* distance across strip */
25     double u= y * 1.0 / (Y-1); /* SGT's u runs 0..1 across the strip */
26
27     /* SGT's v runs 0..pi along the strip, where the join is at 0==pi.
28      * So that corresponds to 0..X (since 0==X in our scheme).
29      * Vertices with odd y coordinate are halfway to the next x coordinate.
30      */
31     double v= (x*2 + (y&1)) * 1.0 / (X*2);
32     v += 0.5;
33     v *= M_PI;
34
35     printf("%-*.*g %-*.*g # %03x %2d %2d\n",
36            prec+5,prec,u, prec+5,prec,v,
37            vi, x, y);
38   }
39   flushoutput();
40   return 0;
41 }