Graph-Maker-Other
view release on metacpan or search on metacpan
devel/lib/MyPlanar.pm view on Meta::CPAN
if (($c1||$c2) && ($c3||$c4)) {
### partial overlap ...
return [$c1 ? $p1 : $p2,
$c3 ? $p3 : $p4];
}
foreach my $a ($p1,$p2) {
foreach my $b ($p3,$p4) {
if ($a->[0]==$b->[0] && $a->[1]==$b->[1]) {
### endpoint in common ...
return [$a,$a];
}
}
}
### try point intersection ...
if (my $p = Math::Geometry::Planar::SegmentIntersection($points)) {
return [$p,$p];
}
return 0;
}
sub distance_segment_to_segment {
my ($points) = @_;
my ($p1,$p2, $p3,$p4) = @$points;
# DistanceToSegment() is +ve on the left and -ve on the right.
# Here want absolute value.
#
# Shortest distance is always attained going to the endpoint of one
# segment, since straight lines.
my $ret;
foreach (0,1) {
foreach my $i (2,3) {
my $d = abs(DistanceToSegment([$points->[0],$points->[1],$points->[$i]]));
$ret = min($ret // $d, $d)
or return $ret; # if 0
}
$points = [reverse @$points];
lib/Graph/Maker/Catalans.pm view on Meta::CPAN
length are a row of the Catalan triangle.
T rotate_rightarm
/ \
* only rotate edges
/ \ on the right-most arm
* extending down
/ \
In terms of balanced binary, right arm means rotate at "1aaaa0 1" where the
0 there is a return to the zero line. The graph endpoints
(C<$graph-E<gt>successorless_vertices>) have no such returns to zero. They
are "1 balanced(N-1) 0", and hence Catalan(N-1) many.
In terms of C<Ldepths>, right arm vertices have Ldepth=0 and the x,y
vertices of the rotate are consecutive Ldepth=0 (and other non-zeros in
between). The rotate increases the depth of the second.
Csar, Sengupta, and Suksompong get various rightarm results too, as
X<comb poset>"comb poset" of bracketings.
( run in 0.415 second using v1.01-cache-2.11-cpan-2b1a40005be )