chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 1 Mar 2019 00:51:48 +0000 (00:51 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 1 Mar 2019 00:51:48 +0000 (00:51 +0000)
generate-board

index 64500d0dd7ecd18f1797d25ca82027a9941b23bc..fd87a7f4c32b402fdf79cb5d7cb1aba77f424cec 100755 (executable)
@@ -25,6 +25,8 @@ our %vxname2pos; # $vxname2pos{VXNAME} = Math::GSL::Vector
 sub TAU { M_PI * 2.0; }
 sub MM2PT { 72.0 / 25.4; }
 
+our $mid;
+
 # ----- region names from plag, incl. reverse mapping -----
 
 our %prs2region;
@@ -214,6 +216,7 @@ sub transform_coordinates () {
     gsl_vector_add($$pr->raw, $translate->raw) and confess;
     gsl_vector_scale($$pr->raw, $scale) and confess;
   });
+  $mid = $lims[1] - $lims[0];
 }
 
 sub adjust_nz() {
@@ -225,21 +228,21 @@ sub adjust_nz() {
   foreach my $v (@$poly) {
     $v->{NZ_Occurs} = $occurs{$v->{VxName}};
   }
-  my $ei;
   my $occurs_m = sub {
-    my ($delta) = @_;
-    $poly->[($ei+$delta+@$poly) % @$poly]{NZ_Occurs} > 1
+    my ($ei) = @_;
+    $poly->[($ei+@$poly) % @$poly]{NZ_Occurs} > 1
   };
-  for $ei (0..$#$poly) {
-    next if $occurs_m->(0);
-    next unless $occurs_m->(-1);
-    next unless $occurs_m->(+1);
+  for my $ei (0..$#$poly) {
+    next if $occurs_m->($ei);
+    next unless $occurs_m->($ei-1);
+    next unless $occurs_m->($ei+1);
     # adjust coord outwards
   }
-  for $ei (0..$#$poly) {
-    next unless $occurs_m->(-1);
-    next unless $occurs_m->(0);
-    my $pos = \ $poly->{$ei}{Pos};
+  for my $ei (0..$#$poly) {
+    next unless $occurs_m->($ei-1);
+    next unless $occurs_m->($ei);
+    my $pos = \ $poly->[$ei]{Pos};
+    $$pos = $$pos*2 - $mid - Math::GSL::Vector->new([-1400,0]);
   }
 }
 
@@ -277,6 +280,7 @@ prep_region_rmap();
 read_faces();
 calculate_centres();
 transform_coordinates();
+adjust_nz();
 
 o("%!\n");
 o(" 0.52 dup scale\n"); # xxx bodge