Ramer-Douglas-Peucker line simplification: Difference between revisions
Ramer-Douglas-Peucker line simplification (view source)
Revision as of 13:58, 17 June 2017
, 7 years ago→{{header|Perl 6}}: factor out some common code
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: minor simplification) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: factor out some common code) |
||
Line 217:
=={{header|Perl 6}}==
{{works with|Rakudo|
{{trans|C++}}
<lang perl6>sub
sub perpendicular-distance (@start, @end where @end !eqv @start , @point) {
return 0 if @point eqv any(@start, @end);
my ( $Δx,
my ($Δpx, $Δpy) = @point «-» @start;
($Δx, $Δy) «/=»
}
Line 234 ⟶ 236:
my ($index, $dmax) = @d.first: @d.max, :kv;
return Ramer-Douglas-Peucker( @points[0..$index] , ε )[^(*-1)],
if $dmax
@points[0, *-1];
}
|