chiark / gitweb /
mkvec nfc
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 1 Mar 2019 13:37:16 +0000 (13:37 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 1 Mar 2019 13:37:16 +0000 (13:37 +0000)
generate-board

index 2561cbdd0668219aa058b80026e7687a03a5f117..be03bdf84ee1a0825eeb8864e94ccad5028ecbb7 100755 (executable)
@@ -117,7 +117,7 @@ sub read_faces () {
     } elsif (m/^\s+\^adjoins\s+$sre$/) {
       $edges[-1]{Adjoins} = prs2r($2);
     } elsif (m/^\s+\^\@([-e.0-9]+)\,([-e.0-9]+)$/) {
-      my $pos = Math::GSL::Vector->new([$1,$2]);
+      my $pos = mkvec($1,$2);
       confess unless defined $vxname;
       $edges[-1]{Pos} = $pos;
       $vxname2pos{$vxname} = $pos;
@@ -163,6 +163,8 @@ sub prvec ($) {
   sprintf "%g,%g", $v->get(0), $v->get(1);
 }
 
+sub mkvec ($$) { Math::GSL::Vector->new(\@_) }
+
 sub transform_coordinates () {
   # Adjusts coordinates in graph to be [0,0] .. top right (scaled)
   # until it's all in PostScript points
@@ -180,7 +182,7 @@ sub transform_coordinates () {
   my @lims;
   foreach my $topend (qw(0 1)) {
     my $v = $topend ? -$GSL_DBL_MAX : $GSL_DBL_MAX;
-    $lims[$topend] = Math::GSL::Vector->new([$v,$v]);
+    $lims[$topend] = mkvec($v,$v);
   }
   for_each_pos(sub {
     my ($pr, $rr, $why) = @_;
@@ -241,7 +243,7 @@ sub adjust_nz() {
     next unless $occurs_m->($ei);
     print STDERR " nz occurs_m $ei $poly->[$ei]{VxName}\n";
     next unless $occurs_m->($ei-1);
-    my $dleft = Math::GSL::Vector->new([-1000,0]);
+    my $dleft = mkvec(-1000,0);
     foreach my $which (0,-1) {
       my $ej = ($ei +        $which + @$poly) % @$poly;
       my $ek = ($ei + +1 + 3*$which + @$poly) % @$poly;
@@ -312,9 +314,9 @@ sub label_faces() {
   foreach my $rr (values %region) {
     next if $rr->{Special};
     my $words = $rr->{DisplayName};
-    my $pos = $rr->{Centre} + Math::GSL::Vector->new([ 0, 0.5 * $sz * @$words ]);
+    my $pos = $rr->{Centre} + mkvec( 0, 0.5 * $sz * @$words );
     foreach my $word (@$words) {
-      $pos += Math::GSL::Vector->new([0,-$sz]);
+      $pos += mkvec(0,-$sz);
       o("   ", psvec($pos), " moveto");
       o(<<END);
    ($word) dup stringwidth pop     % word xw