chiark / gitweb /
can use original model now
authorIan Jackson <ian@davenant.relativity.greenend.org.uk>
Wed, 2 Jan 2008 01:33:32 +0000 (01:33 +0000)
committerIan Jackson <ian@davenant.relativity.greenend.org.uk>
Wed, 2 Jan 2008 01:33:32 +0000 (01:33 +0000)
.bzrignore
Makefile
approxmodel
generator
library.pl
mgraph.h
primer.c
view.c

index e8f48742a36146c9f79c1d91c4f60b8815a2255b..098b20bd97db6e7eae28cfad00e6e4c66477c733 100644 (file)
@@ -6,3 +6,7 @@ best
 *.d
 *.tmp
 *.new
+core
+vgcore.*
+lumpy
+prime
index b19bbaf5f2f26ee72b17872eb7b1cd560a18ca75..a4b09dca05faae63cfd27247437570fe023b4d90 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,20 +10,28 @@ CXXFLAGS=   -MMD $(OPTIMISE) -g $(CXXWARNS)
 
 LIBGSL= -lgsl -lgslcblas
 
+o= >$@.new && mv -f $@.new $@
+
 all:           $(TARGETS)
 
 minimise:      energy.o bgl.o common.o mgraph.o
                $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBGSL)
 
+prime:         primer
+               ./$^ $o
+
 primer:                primer.o common.o
                $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL)
 
 view:          view.o common.o mgraph.o
                $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) -L/usr/X11R6/lib -lX11
 
-initial:       generator primer sgtatham/z.typescript
+sgtatham:      generator prime sgtatham/z.typescript
                ./$^ -T -o$@
 
+lumpy:         approxmodel prime ../moebius/ins-new ../moebius/a.out
+               ./$^ -o$@
+
 clean:
                rm -f *.o $(TARGETS) *.new *.tmp *.rej *.orig core vgcore.*
                rm -f initial
index c1c7d36d433910f6208e0a75705a566e62a837f7..cbe1799b096d3f0fa977614f4f9312fd48a7b513 100755 (executable)
@@ -1,18 +1,37 @@
 #!/usr/bin/perl
 require 'library.pl';
 die unless @ARGV==4;
-($primer,$instructions,$aout,$output) = @ARGV;
+($prime,$instructions,$aout,$output) = @ARGV;
 $output =~ s/^\-o// or die "$output ?";
-die if $primer =~ m/^\-/;
+die if $prime =~ m/^\-/;
 die if $instructions =~ m/^\-/;
 
 $aoutin= "$output.aoutin.tmp";
 $initdata= "$output.initdata.tmp";
 
 run("cat $instructions >$aoutin");
-run("./$primer 'pointmap ' ' ' ' ' ' ' ' ' ' # '  'echo ' ' ' u >>$aoutin");
 
 open A, ">>$aoutin" or die $!;
+
+use Math::Trig;
+
+sub initdata_prime_point_callback ($$$$) {
+    my ($u,$v,$comment,$floatformat) = @_; # SGT's coordinates
+    # v corresponds to the old program's t, roughly
+    printf(A "pointmap $floatformat $floatformat %s\n",
+          $v/(pi), $u, $comment)
+       or die $!;
+}
+
+sub initdata_return_vertex_transform () {
+    ($vertex[0],$vertex[2])= ($vertex[2],$vertex[0]);
+    map { $_ *= 0.7 } @vertex;
+    $vertex[1] *= -1;
+    $vertex[1] += 0.5;
+}
+
+initdata_process_prime();
+
 print A "quit\n" or die $!;
 close A or die $!;
     
index 6cdbab295e8d404f1db559e5fdc590e62d53e2af..181285081d317dd1184404eb64b5596e8bd32d2b 100755 (executable)
--- a/generator
+++ b/generator
@@ -1,9 +1,9 @@
 #!/usr/bin/perl
 require 'library.pl';
 die unless @ARGV==4;
-($primer,$zinput,$options,$output) = @ARGV;
+($prime,$zinput,$options,$output) = @ARGV;
 $output =~ s/^\-o// or die "$output ?";
-die if $primer =~ m/^\-/;
+die if $prime =~ m/^\-/;
 die if $zinput =~ m/^\-/;
 
 die unless $options =~ m/^\-([gTa])$/;
@@ -31,10 +31,24 @@ for (;;) {
 }
 
 printf G "set print \"-\"\n" or die $!;
+
+sub initdata_prime_point_callback ($$$$) {
+    my ($u,$v,$comment,$floatformat) = @_; # SGT's coordinates
+    for ($k=0; $k<3; $k++) {
+       printf(G "print %s( $floatformat, $floatformat ) ;%s\n",
+              qw(x y z)[$k], $u, $v, $comment)
+           or die $!;
+    }
+}
+
+sub initdata_return_vertex_transform () {
+    $vertex[1] *= -1;
+}
+
+initdata_process_prime();
+
 close G or die $!;
 
-run("./$primer 'print ' '+-+' 'xyz' '( ' ', ' ');  # ' ".
-    "'print ' ', ' - >>$gnuplot");
 run("gnuplot $gnuplot >$initdata");
 
 make_initdata();
index cb7a59b42f0689cd1984c28676c27be11a4923cf..d95f61932a55aa69f12e9b93786e3e7a806aaeb8 100644 (file)
@@ -3,21 +3,34 @@ sub run ($) {
     $!=0; system($_[0]); die "$! $?" if $! or $?;
 }
 
+sub initdata_process_prime() {
+    my ($i,$fmt);
+    open P, "$prime" or die $!;
+    $!=0; $_= <P>; m/^(\d+) (\d+) .*/ or die "$_ ? $!";
+    ($dim,$nvertices)= ($1,$2);
+    $!=0; $_= <P>; m/^(\%.*)\n/ or die "$_ ? $!";
+    $fmt= $1;
+    for ($i=0; $i<$nvertices; $i++) {
+       $!=0; defined($_=<P>) or die "$prime $!";
+       m/^\s*(\S+)\s*(\S+)\s*(.*)/ or die "$_ ?";
+       initdata_prime_point_callback($1,$2,$3,$fmt);
+    }
+}
+
 sub make_initdata () {
     open I, "$initdata" or die "$initdata $!";
     open B, ">$output.new" or die "$output.new $!";
 
-    $_= <I>;
-    m/^(\d+) .*/ or die "$_ ?";
-
-    $dim= $1;
-
-    for ($i=0; $i<$dim; $i++) {
-       for (;;) {
-           $!=0; defined($_= <I>) or die "$initdata $!";
-           last if m/\S/;
+    for ($i=0; $i<$nvertices; $i++) {
+       for ($k=0; $k<3; $k++) {
+           for (;;) {
+               $!=0; defined($_= <I>) or die "$initdata $!";
+               last if m/\S/;
+           }
+           $vertex[$k]= $_;
        }
-       print B pack "d", $_ or die $!;
+       initdata_return_vertex_transform();
+       print B pack "d3", @vertex or die $!;
     }
 
     close B or die $!;
index ba3ec29807ae2103a27ff7ec41d6e9fe15d9fb29..e3079787033836ff8845816f94c5825a9a51afb5 100644 (file)
--- a/mgraph.h
+++ b/mgraph.h
@@ -62,7 +62,7 @@
 
 #include "common.h"
 
-#define XBITS 3
+#define XBITS 6 /*3*/
 #define X (1<<XBITS)
 #define YBITS 4
 #define Y ((1<<YBITS) - 1)
index 1ec587dedbbf8a323df0a75e7421ff06fd0ced0a..1f87036119b45ac54d2fc254276031e727290b96 100644 (file)
--- a/primer.c
+++ b/primer.c
@@ -9,14 +9,14 @@
 
 int main(int argc, const char **argv) {
   static const int prec= DBL_DIG+2;
-  int vi, k;
+  int vi;
   
-  if (argc!=10 || !strlen(argv[2]) || strlen(argv[2]) != strlen(argv[3]))
-    { fputs("wrong # args or lengths\n",stderr); exit(8); }
+  if (argc!=1) { fputs("need no args\n",stderr); exit(8); }
+
+  printf("%d %d %d %d %d\n%%-%d.%dg\n",
+        DIM, N, X, Y, D3,
+        prec+5,prec);
 
-  printf("%s%d%s%d%s%d%s%d%s%d\n",
-        argv[7], DIM, argv[8], N, argv[8], X, argv[8], Y, argv[8], D3);
-  
   FOR_VERTEX(vi) {
     int x= vi & XMASK; /* distance along strip */
     int y= vi >> YSHIFT; /* distance across strip */
@@ -26,18 +26,11 @@ int main(int argc, const char **argv) {
      * 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)) * 1.0 / (X*2);
+    double v= (x*2 + (y&1)) * M_PI / (X*2);
 
-    if (!strchr(argv[9],'u'))
-      v *= M_PI;
-    
-    K {
-      if (k >= strlen(argv[2])) break;
-      printf("%s%c%c%s%-*.*g%s%-*.*g%s%03x %2d %2d\n",
-            argv[1], argv[2][k], argv[3][k], argv[4],
-            prec+5,prec,u, argv[5], prec+5,prec,v,
-            argv[6], vi, x, y);
-    }
+    printf("%-*.*g %-*.*g # %03x %2d %2d\n",
+          prec+5,prec,u, prec+5,prec,v,
+          vi, x, y);
   }
   flushoutput();
   return 0;
diff --git a/view.c b/view.c
index 742db8075e6d3e9df854397fd4441079673d5d79..d2650113e0d00f98d703c67928f2aa072a6ea0b6 100644 (file)
--- a/view.c
+++ b/view.c
@@ -84,9 +84,12 @@ static void generate_display_list(void) {
      * orientable so it shouldn't matter).  Picking the parallelogram
      * to our right avoids getting it wrong at the join.
      */
+//if ((vb & YMASK) > Y1) continue;
+//if ((vb & XMASK) > 2) continue; 
     for (e=0; e<V6; e++) ve[e]= EDGE_END2(vb,e);
     assert(ve[0]>=0);
     if (ve[5]>=0) addtriangle(vb,ve[0],ve[5]);
+//continue;
     if (ve[1]>=0) addtriangle(vb,ve[1],ve[0]);
   }
 
@@ -97,7 +100,7 @@ static void generate_display_list(void) {
       if (vertex_in_triangles[v] != expd) {
        fprintf(stderr,"vertex %02x used for %d triangles, expected %d\n",
                v, vertex_in_triangles[v], expd);
-       abort();
+//     abort();
       }
     }
     vertex_in_triangles_checked= 1;