1Math::Polygon::Clip(3)User Contributed Perl DocumentationMath::Polygon::Clip(3)
2
3
4

NAME

6       Math::Polygon::Clip - frame a polygon in a square
7

INHERITANCE

9        Math::Polygon::Clip
10          is a Exporter
11

SYNOPSIS

13        my @poly  = ( [1,2], [2,4], [5,7], [1, 2] );
14        my @box   = ( $xmin, $ymin, $xmax, $ymax );
15
16        my $boxed = polygon_clip \@box, @poly;
17

DESCRIPTION

19       Cut-off all parts of the polygon which are outside the box
20

FUNCTIONS

22       polygon_fill_clip1(\@box, @points)
23           Clipping a polygon into rectangles can be done in various ways.
24           With this algorithm (which I designed myself, but may not be new),
25           the parts of the polygon which are outside the @box are mapped on
26           the borders.  The polygon stays in one piece.
27
28           Returned is one list of points, which is cleaned from double
29           points, spikes and superfluous intermediate points.
30
31       polygon_fill_clip2(\@box, @points)
32           To be implemented.  The polygon falls apart in fragments, which are
33           not connected: paths which are followed in two directions are
34           removed.  This is required by some applications, like polygons used
35           in geographical context (country contours and such).
36
37       polygon_fill_clip3( \@box, $out-$poly, [$in-$polys] )
38           To be implemented.  A surrounding polygon, with possible
39           inclussions.
40
41       polygon_line_clip(\@box, @points)
42           Returned is a list of ARRAYS (possibly 0 long) containing line
43           pieces from the input polygon (or line).
44
45           example:
46
47            my @points = ( [1,2], [2,3], [2,0], [1,-1], [1,2] );
48            my @bbox   = ( 0, -2, 2, 2 );
49            my @l      = polygon_line_clip \@bbox, @points;
50            print scalar @l;      # 1, only one piece found
51            my @first = @{$l[0]}; # first is [2,0], [1,-1], [1,2]
52

SEE ALSO

54       This module is part of Math-Polygon distribution version 1.10, built on
55       January 03, 2018. Website: http://perl.overmeer.net/CPAN/
56

LICENSE

58       Copyrights 2004-2018 by [Mark Overmeer]. For other contributors see
59       ChangeLog.
60
61       This program is free software; you can redistribute it and/or modify it
62       under the same terms as Perl itself.  See http://dev.perl.org/licenses/
63
64
65
66perl v5.30.1                      2020-01-30            Math::Polygon::Clip(3)
Impressum