From: ian Date: Wed, 4 Feb 2004 00:09:00 +0000 (+0000) Subject: fix comment for ev_byang; horrid broken join arcline attempt needs rewrite X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=16fe6584d75a4ad84e9b88417abd494c1e20eae8;p=trains.git fix comment for ev_byang; horrid broken join arcline attempt needs rewrite --- diff --git a/layout/layout b/layout/layout index c2c46d0..fc63491 100755 --- a/layout/layout +++ b/layout/layout @@ -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) { diff --git a/layout/testjoin.m4 b/layout/testjoin.m4 index 13e46f0..5dcf48f 100644 --- a/layout/testjoin.m4 +++ b/layout/testjoin.m4 @@ -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)