Debian Codegraph @

lib/Math/Polygon/Surface.pod

raw
1 =encoding utf8
2
3 =head1 NAME
4
5 Math::Polygon::Surface - Polygon with exclusions
6
7 =head1 SYNOPSIS
8
9 my $outer = Math::Polygon->new( [1,2], [2,4], [5,7], [1,2] );
10 my $surface = Math::Polygon::Surface->new($outer);
11
12 =head1 DESCRIPTION
13
14 A surface is one polygon which represents the outer bounds of an
15 array, plus optionally a list of polygons which represent exclusions
16 from that outer polygon.
17
18 =head1 METHODS
19
20 =head2 Constructors
21
22 =over 4
23
24 =item $any-E<gt>B<new>( [%options], [@polygons], %options )
25
26 You may merge C<%options> with C<@polygons>. You may also use
27 the "outer" and "inner" options.
28
29 Each polygon is a references to an ARRAY of points, each an ARRAY of X
30 and Y, but better pass L<Math::Polygon|Math::Polygon> objects.
31
32 -Option--Default
33 inner []
34 outer undef
35
36 =over 2
37
38 =item inner => \@polygons
39
40 The inner C<@polygons>, zero or more L<Math::Polygon|Math::Polygon> objects.
41
42 =item outer => $polygon
43
44 The outer C<$polygon>, a L<Math::Polygon|Math::Polygon>.
45
46 =back
47
48 =back
49
50 =head2 Attributes
51
52 =over 4
53
54 =item $obj-E<gt>B<inner>()
55
56 Returns a list (often empty) of inner polygons.
57
58 =item $obj-E<gt>B<outer>()
59
60 Returns the outer polygon.
61
62 =back
63
64 =head2 Simple calculations
65
66 =over 4
67
68 =item B<area>()
69
70 Returns the area enclosed by the outer polygon, minus the areas of the
71 inner polygons.
72 See method L<Math::Polygon::area()|Math::Polygon/"Geometry">.
73
74 =item $obj-E<gt>B<bbox>()
75
76 Returns a list with four elements: (xmin, ymin, xmax, ymax), which describe
77 the bounding box of the surface, which is the bbox of the outer polygon.
78 See method L<Math::Polygon::bbox()|Math::Polygon/"Geometry">.
79
80 =item $obj-E<gt>B<perimeter>()
81
82 The length of the border: sums outer and inner perimeters.
83 See method L<Math::Polygon::perimeter()|Math::Polygon/"Geometry">.
84
85 =back
86
87 =head2 Clipping
88
89 =over 4
90
91 =item $obj-E<gt>B<fillClip1>($box)
92
93 Clipping a polygon into rectangles can be done in various ways.
94 With this algorithm, the parts of the polygon which are outside
95 the C<$box> are mapped on the borders.
96
97 All polygons are treated separately.
98
99 =item $obj-E<gt>B<lineClip>($box)
100
101 Returned is a list of ARRAYS-OF-POINTS containing line pieces
102 from the input surface. Lines from outer and inner polygons are
103 undistinguishable.
104 See method L<Math::Polygon::lineClip()|Math::Polygon/"Clipping">.
105
106 =item $obj-E<gt>B<string>()
107
108 Translate the surface structure into some string. Use Geo::WKT if you
109 need a standardized format.
110
111 Returned is a single string possibly containing multiple lines. The first
112 line is the outer, the other lines represent the inner polygons.
113
114 =back
115
116 =head1 DIAGNOSTICS
117
118 =over 4
119
120 =item Error: surface requires outer polygon
121
122 Cast by new()
123
124 =back
125
126 =head1 SEE ALSO
127
128 This module is part of Math-Polygon version 2.00,
129 built on September 04, 2025. Website: F<http://perl.overmeer.net/CPAN/>
130
131 =head1 LICENSE
132
133 For contributors see file ChangeLog.
134
135 This software is copyright (c) 2004-2025 by Mark Overmeer.
136
137 This is free software; you can redistribute it and/or modify it under
138 the same terms as the Perl 5 programming language system itself.
139