This file is indexed.

/usr/share/perl5/Math/Polygon.pod is in libmath-polygon-perl 1.10-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
=encoding utf8

=head1 NAME

Math::Polygon - Class for maintaining polygon data

=head1 SYNOPSIS

 my $poly = Math::Polygon->new( [1,2], [2,4], [5,7], [1,2] );
 print $poly->nrPoints;
 my @p    = $poly->points;

 my ($xmin, $ymin, $xmax, $ymax) = $poly->bbox;

 my $area   = $poly->area;
 my $l      = $poly->perimeter;
 if($poly->isClockwise) { ... };
 
 my $rot    = $poly->startMinXY;
 my $center = $poly->centroid;
 if($poly->contains($point)) { ... };

 my $boxed  = $poly->lineClip($xmin, $xmax, $ymin, $ymax);

=head1 DESCRIPTION

This class provides an Object Oriented interface around
L<Math::Polygon::Calc|Math::Polygon::Calc>, L<Math::Polygon::Clip|Math::Polygon::Clip>, and other.  Together,
these modules provide basic transformations on 2D polygons in pure perl.

B<WARNING:> these computations may show platform dependent ronding
differences.  These may also originate from compilation options of
the Perl version you installed.

=head1 METHODS

=head2 Constructors

=over 4

=item $obj-E<gt>B<new>(%options, [@points], %options)

=item Math::Polygon-E<gt>B<new>(%options, [@points], %options)

You may add %options before and/or after the @points.  You may also use
the "points" option to set the points.  Each point in @points is
(a references) to an ARRAY with two elements: an X and a Y coordinate.

When C<new()> is called as instance method, it is believed that the
new polygon is derived from the callee, and therefore some facts
(like clockwise or anti-clockwise direction) will get copied unless
overruled.

 -Option   --Default
  bbox       undef
  clockwise  undef
  points     undef

=over 2

=item bbox => [$xmin,$ymin, $xmax,$ymax]

Usually computed from the shape automatically, but can also be
overruled. See L<bbox()|Math::Polygon/"Geometry">.

=item clockwise => BOOLEAN

Is not specified, it will be computed by the L<isClockwise()|Math::Polygon/"Geometry"> method
on demand.

=item points => \@points

See L<points()|Math::Polygon/"Attributes"> and L<nrPoints()|Math::Polygon/"Attributes">.

=back

example: creation of new polygon

 my $p = Math::Polygon->new([1,0],[1,1],[0,1],[0,0],[1,0]);

 my @p = ([1,0],[1,1],[0,1],[0,0],[1,0]);
 my $p = Math::Polygon->new(points => \@p);

=back

=head2 Attributes

=over 4

=item $obj-E<gt>B<nrPoints>()

Returns the number of points,

=item $obj-E<gt>B<order>()

Returns the number of (unique?) points: one less than L<nrPoints()|Math::Polygon/"Attributes">.

=item $obj-E<gt>B<point>( $index, [$index,...] )

Returns the point with the specified $index or INDEXES.  In SCALAR context,
only the first $index is used.

example: 

  my $point = $poly->point(2);
  my ($first, $last) = $poly->point(0, -1);

=item $obj-E<gt>B<points>( [FORMAT] )

In LIST context, the points are returned as list, otherwise as
reference to an ARRAY of points.

[1.09] When a FORMAT is given, each coordinate will get processed.
This may be useful to hide platform specific rounding errors.  FORMAT
may be a CODE reference or a C<printf()> alike string.
See L<Math::Polygon::Calc::polygon_format()|Math::Polygon::Calc/"FUNCTIONS">.

example: 

  my @points = $poly->points;
  my $first  = $points[0];
  my $x0 = $points[0][0];    # == $first->[0]  --> X
  my $y0 = $points[0][1];    # == $first->[1]  --> Y

  my @points = $poly->points("%.2f");

=back

=head2 Geometry

=over 4

=item $obj-E<gt>B<area>()

Returns the area enclosed by the polygon.  The last point of the list
must be the same as the first to produce a correct result.  The computed
result is cached.
Function L<Math::Polygon::Calc::polygon_area()|Math::Polygon::Calc/"FUNCTIONS">.

example: 

  my $area = $poly->area;
  print "$area $poly_units ^2\n";

=item $obj-E<gt>B<bbox>()

Returns a list with four elements: (xmin, ymin, xmax, ymax), which describe
the bounding box of the polygon (all points of the polygon are inside that
area).  The computation is expensive, and therefore, the results are
cached.
Function L<Math::Polygon::Calc::polygon_bbox()|Math::Polygon::Calc/"FUNCTIONS">.

example: 

  my ($xmin, $ymin, $xmax, $ymax) = $poly->bbox;

=item $obj-E<gt>B<beautify>(%options)

Returns a new, beautified version of this polygon.
Function L<Math::Polygon::Calc::polygon_beautify()|Math::Polygon::Calc/"FUNCTIONS">.

Polygons, certainly after some computations, can have a lot of horrible
artifacts: points which are double, spikes, etc.  This functions provided
by this module beautify them.  A new polygon is returned.

 -Option       --Default
  remove_spikes  <false>

=over 2

=item remove_spikes => BOOLEAN

=back

=item $obj-E<gt>B<centroid>()

Returns the centroid location of the polygon.  The last point of the list
must be the same as the first to produce a correct result.  The computed
result is cached.  Function L<Math::Polygon::Calc::polygon_centroid()|Math::Polygon::Calc/"FUNCTIONS">.

example: 

  my $center = $poly->centroid;
  my ($cx, $cy) = @$center;

=item $obj-E<gt>B<clockwise>()

Make sure the points are in clockwise order.

example: 

  $poly->clockwise;

=item $obj-E<gt>B<contains>($point)

Returns a truth value indicating whether the point is inside the polygon
or not.  On the edge is inside.

=item $obj-E<gt>B<counterClockwise>()

Make sure the points are in counter-clockwise order.

example: 

  $poly->counterClockwise

=item $obj-E<gt>B<distance>($point)

[1.05] Returns the distance of the point to the closest point on the border of
the polygon, zero if the point is on an edge.

=item $obj-E<gt>B<equal>( <$other | \@points,[$tolerance]> | $points )

Compare two polygons, on the level of points. When the polygons are
the same but rotated, this will return false. See L<same()|Math::Polygon/"Geometry">.
Function L<Math::Polygon::Calc::polygon_equal()|Math::Polygon::Calc/"FUNCTIONS">.

example: 

  if($poly->equal($other_poly, 0.1)) ...
  if($poly->equal(\@points, 0.1)) ...
  if($poly->equal(@points)) ...

=item $obj-E<gt>B<isClockwise>()

The points are (in majority) orded in the direction of the hands of the clock.
This calculation is quite expensive (same effort as calculating the area of
the polygon), and the result is therefore cached.

example: 

  if($poly->isClockwise) ...

=item $obj-E<gt>B<isClosed>()

Returns true if the first point of the poly definition is the same
as the last point.

=item $obj-E<gt>B<perimeter>()

The length of the line of the polygon.  This can also be used to compute
the length of any line: of the last point is not equal to the first, then
a line is presumed; for a polygon they must match.
Function L<Math::Polygon::Calc::polygon_perimeter()|Math::Polygon::Calc/"FUNCTIONS">.

example: 

 my $fence = $poly->perimeter;
 print "fence length: $fence $poly_units\n"

=item $obj-E<gt>B<same>( <$other_polygon | \@points, [$tolerance]> | @points )

Compare two polygons, where the polygons may be rotated wrt each
other. This is (much) slower than L<equal()|Math::Polygon/"Geometry">, but some algorithms
will cause un unpredictable rotation in the result.
Function L<Math::Polygon::Calc::polygon_same()|Math::Polygon::Calc/"FUNCTIONS">.

example: 

  if($poly->same($other_poly, 0.1)) ...
  if($poly->same(\@points, 0.1)) ...
  if($poly->same(@points)) ...

=item $obj-E<gt>B<startMinXY>()

Returns a new polygon object, where the points are rotated in such a way
that the point which is losest to the left-bottom point of the bounding
box has become the first.

Function L<Math::Polygon::Calc::polygon_start_minxy()|Math::Polygon::Calc/"FUNCTIONS">.

=back

=head2 Transformations

Implemented in L<Math::Polygon::Transform|Math::Polygon::Transform>: changes on the structure of
the polygon except clipping.  All functions return a new polygon object
or undef.

=over 4

=item $obj-E<gt>B<grid>(%options)

Returns a polygon object with the points snapped to grid points.
See L<Math::Polygon::Transform::polygon_grid()|Math::Polygon::Transform/"FUNCTIONS">.

 -Option--Default
  raster  1.0

=over 2

=item raster => FLOAT

The raster size, which determines the points to round to.  The origin
C<[0,0]> is always on a grid-point.  When the raster value is zero,
no transformation will take place.

=back

=item $obj-E<gt>B<mirror>(%options)

Mirror the polygon in a line.  Only one of the options can be provided.
Some programs call this "flip" or "flop".

 -Option--Default
  b       0
  line    <undef>
  rc      undef
  x       undef
  y       undef

=over 2

=item b => FLOAT

Only used in combination with option C<rc> to describe a line.

=item line => [POINT, POINT]

Alternative way to specify the mirror line.  The C<rc> and C<b> are
computed from the two points of the line.

=item rc => FLOAT

Description of the line which is used to mirror in. The line is
C<y= rc*x+b>.  The C<rc> equals C<-dy/dx>, the firing angle.  If
C<undef> is explicitly specified then C<b> is used as constant x: it's
a vertical mirror.

=item x => FLOAT

Mirror in the line C<x=value>, which means that C<y> stays unchanged.

=item y => FLOAT

Mirror in the line C<y=value>, which means that C<x> stays unchanged.

=back

=item $obj-E<gt>B<move>(%options)

Returns a moved polygon object: all point are moved over the
indicated distance.  See L<Math::Polygon::Transform::polygon_move()|Math::Polygon::Transform/"FUNCTIONS">.

 -Option--Default
  dx      0
  dy      0

=over 2

=item dx => FLOAT

Displacement in the horizontal direction.

=item dy => FLOAT

Displacement in the vertical direction.

=back

=item $obj-E<gt>B<resize>(%options)

Returns a resized polygon object.
See L<Math::Polygon::Transform::polygon_resize()|Math::Polygon::Transform/"FUNCTIONS">.

 -Option--Default
  center  [0,0]
  scale   1.0
  xscale  <scale>
  yscale  <scale>

=over 2

=item center => $point

=item scale => FLOAT

Resize the polygon with the indicated factor.  When the factor is larger
than 1, the resulting polygon with grow, when small it will be reduced in
size.  The scale will be respective from the center.

=item xscale => FLOAT

Specific scaling factor in the horizontal direction.

=item yscale => FLOAT

Specific scaling factor in the vertical direction.

=back

=item $obj-E<gt>B<rotate>(%options)

Returns a rotated polygon object: all point are moved over the
indicated distance.  See L<Math::Polygon::Transform::polygon_rotate()|Math::Polygon::Transform/"FUNCTIONS">.

 -Option --Default
  center   [0,0]
  degrees  0
  radians  0

=over 2

=item center => POINT

=item degrees => FLOAT

specify rotation angle in degrees (between -180 and 360).

=item radians => FLOAT

specify rotation angle in rads (between -pi and 2*pi)

=back

=item $obj-E<gt>B<simplify>(%options)

Returns a polygon object where points are removed.
See L<Math::Polygon::Transform::polygon_simplify()|Math::Polygon::Transform/"FUNCTIONS">.

 -Option    --Default
  max_points  undef
  same        0.0001
  slope       undef

=over 2

=item max_points => INTEGER

First, C<same> and C<slope> reduce the number of points.  Then, if there
are still more than the specified number of points left, the points with
the widest angles will be removed until the specified maximum number is
reached.

=item same => FLOAT

The distance between two points to be considered "the same" point.  The value
is used as radius of the circle.

=item slope => FLOAT

With three points X(n),X(n+1),X(n+2), the point X(n+1) will be removed if
the length of the path over all three points is less than C<slope> longer
than the direct path between X(n) and X(n+2).

The slope will not be removed around the starting point of the polygon.
Removing points will change the area of the polygon.

=back

=back

=head2 Clipping

=over 4

=item $obj-E<gt>B<fillClip1>($box)

Clipping a polygon into rectangles can be done in various ways.
With this algorithm, the parts of the polygon which are outside
the $box are mapped on the borders.  The polygon stays in one piece,
but may have vertices which are followed in two directions.

Returned is one polygon, which is cleaned from double points,
spikes and superfluous intermediate points, or C<undef> when
no polygon is outside the $box.
Function L<Math::Polygon::Clip::polygon_fill_clip1()|Math::Polygon::Clip/"FUNCTIONS">.

=item $obj-E<gt>B<lineClip>($box)

Returned is a list of ARRAYS-OF-POINTS containing line pieces
from the input polygon.
Function L<Math::Polygon::Clip::polygon_line_clip()|Math::Polygon::Clip/"FUNCTIONS">.

=back

=head2 Display

=over 4

=item $obj-E<gt>B<string>( [FORMAT] )

Print the polygon.

[1.09] When a FORMAT is specified, all coordinates will get formatted
first.  This may hide platform dependent rounding differences.

=back

=head1 SEE ALSO

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

=head1 LICENSE

Copyrights 2004-2018 by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>