chiark / gitweb /
new topology; check that graph and stuff makes sense
[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, k;
13   
14   if (argc>1) { fputs("no args please\n",stderr); exit(8); }
15
16   printf("print %d, %d, %d, %d, %d\n", DIM, N, X, Y, D3);
17   
18   FOR_VERTEX(vi) {
19     int x= vi & XMASK; /* distance along strip */
20     int y= vi >> YSHIFT; /* distance across strip */
21     double u= y * 1.0 / (Y-1); /* SGT's u runs 0..1 across the strip */
22
23     /* SGT's v runs 0..pi along the strip, where the join is at 0==pi.
24      * So that corresponds to 0..X (since 0==X in our scheme). */
25     double v= (x*2 + (y&1)) * M_PI / (X*2);
26
27     K printf("print %c%c( %-*.*g, %-*.*g);  # %03x %2d %2d\n",
28              "+-+"[k], "xyz"[k],
29              prec+5,prec,u, prec+5,prec,v,
30              vi, x, y);
31   }
32   flushoutput();
33   return 0;
34 }