chiark / gitweb /
compute initial layout - not yet checked
[moebius2.git] / primer.c
diff --git a/primer.c b/primer.c
new file mode 100644 (file)
index 0000000..eaa3459
--- /dev/null
+++ b/primer.c
@@ -0,0 +1,28 @@
+/*
+ * Generates the repetitive part of the gnuplot input
+ * for generating the initial triangle vertices from SGT's
+ * model.
+ */
+
+#include "common.h"
+#include "mgraph.h"
+
+int main(int argc, const char **argv) {
+  int v, 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);
+  }
+  flushoutput();
+  return 0;
+}