chiark / gitweb /
fix comment for ev_byang; horrid broken join arcline attempt needs rewrite
authorian <ian>
Wed, 4 Feb 2004 00:09:00 +0000 (00:09 +0000)
committerian <ian>
Wed, 4 Feb 2004 00:09:00 +0000 (00:09 +0000)
layout/layout
layout/testjoin.m4

index c2c46d0e14e952a7d8e0a85142f0945d3afa3baf..fc634915a20a12ae22b555de42e625356b355190 100755 (executable)
@@ -103,7 +103,7 @@ our $debug=0;
 
 sub ev_byang ($$;$) {
     # ev_byang(R, ANG,[LEN])
-    # result is evec of specified angle and length (default=1.0)
+    # result is evec LEN (default=1.0) from origin pointing in direction ANG
     my ($res,$ang,$len)=@_;
     $len=1.0 unless defined $len;
     $res->{X}= $len * cos($ang);
@@ -611,6 +611,41 @@ sub cmd_join {
            }
        }
     }
+    {
+       # one circular arc and a straight line
+       my ($inv,$a,$b, $gamma, $kl_len,$cosag,$aj_len);
+       my ($jl_len, $j,$l,$cl_len,$c, $radius);
+#      foreach $inv (qw(-1 +1)) {
+       {   $inv=-1;
+           $a= $from;
+           $b= { %$to }; $b->{A} += $pi;
+           ($a,$b)=($b,$a) if $inv<0;
+print STDERR "a=".loc2dbg($a)." b=".loc2dbg($b)."\n";
+#          $b= ev_compose({}, $b, {X=>0,Y=>0,A=>$pi});
+           $gamma= 0.5 * ($a->{A} + $b->{A});
+           $gamma += $pi if a_normalise($gamma - $a->{A}, 0) >= $pi;
+           $kl_len=  ($b->{X} - $a->{X}) * cos($gamma)
+                   + ($b->{Y} - $a->{Y}) * sin($gamma);
+           o("%     arcline $inv gamma=".ang2deg($gamma)." |kl|=$kl_len ");
+#          if ($kl_len < 1e-6) { o("nope\n"); next; }
+           $cosag= cos($a->{A} - $gamma);
+           o("cos(a-g)=$cosag ");
+#          if ($cosag < 1e-6) { o("nope\n"); next; }
+           $aj_len= $kl_len/$cosag;
+           o("|aj|=$aj_len\n");
+           $j= ev_compose({}, $a, { X=>$aj_len, Y=>0, A=>0 });
+           $l= ev_lincomb({}, $j,$b,0.5);
+           $jl_len= v_dist($j,$l);
+           $cl_len= $jl_len * tan($a->{A} - $gamma);
+           $radius= $jl_len / $cosag;
+           $c= ev_compose({}, $l, { X=>-$cl_len, Y=>0, A=>0 });
+           push @paths, [{ T => Line, A => $a, B => $j, L => $aj_len },
+                         { T => Arc, F => $j, C => $c, R => $inv*$radius,
+                           D => -$inv * a_normalise
+                               (-$inv * ($b->{A} + $pi - $a->{A}), 0) }];
+           push @solkinds, [ 'arcline' ];
+       }
+    }
     my ($path,$segment,$bestpath,$len,$scores,$bestscores,@bends,$skl);
     my ($crit,$cs,$i,$cmp);
     foreach $path (@paths) {
index 13e46f0555c6e041b73c414d51a4fd2e135d60f0..5dcf48fdc31553dcd639c9ba2ee2e2474b27b67a 100644 (file)
@@ -13,19 +13,19 @@ define(`complex',`
 abs org$1 $2 $3 0
 rel org$1 a$1 0 0 $4
 rel org$1 b$1 200 0 0
- simple(0,$1)
- simple(30,$1)
- simple(60,$1)
+# simple(0,$1)
+# simple(30,$1)
+# simple(60,$1)
  simple(90,$1)
- simple(135,$1)
- simple(230,$1)
- simple(300,$1)
- simple(345,$1)
+# simple(135,$1)
+# simple(230,$1)
+# simple(300,$1)
+# simple(345,$1)
 ')
 
- complex(0,     200,  400,    0)
+# complex(0,     200,  400,    0)
  complex(30,    200, 1200,   30)
- complex(60,    800,  400,   60)
- complex(130,   800, 1200,  130)
- complex(m130, 1500,  400, -130)
- complex(m165, 1500, 1200, -165)
+# complex(60,    800,  400,   60)
+# complex(130,   800, 1200,  130)
+# complex(m130, 1500,  400, -130)
+# complex(m165, 1500, 1200, -165)