=head1 NAME
Math::Polygon::Calc - Simple polygon calculations
=head1 INHERITANCE
Math::Polygon::Calc
is a Exporter
=head1 SYNOPSIS
my @poly = ( [1,2], [2,4], [5,7], [1, 2] );
my ($xmin, $ymin, $xmax, $ymax) = polygon_bbox @poly;
my $area = polygon_area @poly;
MY $L = polygon_perimeter @poly;
if(polygon_is_clockwise @poly) { ... };
my @rot = polygon_start_minxy @poly;
=head1 DESCRIPTION
This package contains a wide variaty of relatively easy polygon
calculations. More complex calculations are put in separate
packages.
=head1 FUNCTIONS
=over 4
=item B(LIST-OF-POINTS)
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 algorithm was found at L,
and sounds:
A = abs( 1/2 * (x1y2-x2y1 + x2y3-x3y2 ...)
=item B(LIST-OF-POINTS)
Returns a list with four elements: (xmin, ymin, xmax, ymax), which describe
the bounding box of the polygon (all points of the polygon are within that
area.
=item B([HASH], LIST-OF-POINTS)
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
The optional HASH contains the OPTIONS:
-Option --Default
remove_between
remove_spikes
=over 2
=item remove_between => BOOLEAN
Simple points in-between are always removed, but more complex
points are not: when the line is not parallel to one of the axes,
more intensive calculations must take place. This will only be
done when this flags is set.
NOT IMPLEMENTED YET
=item remove_spikes => BOOLEAN
=back
=item B(LIST-OF-POINTS)
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 algorithm was found at
F
=item B(LIST-OF-POINTS)
Be sure the polygon points are in clockwise order.
=item B(POINT, LIST-OF-POINTS)
Returns true if the point is unside the closed polygon.
=item B(LIST-OF-POINTS)
Be sure the polygon points are in counter-clockwise order.
=item B(ARRAY-OF-POINTS, ARRAY-OF-POINTS, [TOLERANCE])
Compare two polygons, on the level of points. When the polygons are
the same but rotated, this will return false. See L.
=item B(LIST-OF-POINTS)
=item B(POINTS)
=item B(LIST-OF-POINTS)
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.
This is simply Pythagoras.
$l = sqrt((x1-x0)^2 + (y1-y0)^2) + sqrt((x2-x1)^2+(y2-y1)^2) + ...
=item B(ARRAY-OF-POINTS, ARRAY-OF-POINTS, [TOLERANCE])
Compare two polygons, where the polygons may be rotated wrt each
other. This is (much) slower than L, but some algorithms
will cause un unpredictable rotation in the result.
=item B(LIST-OF-POINTS)
Returns the polygon, where the point which is closest to the left-bottom
corner of the bounding box is made first.
=item B(LIST-OF-POINTS)
=back
=head1 SEE ALSO
This module is part of Math-Polygon distribution version 1.02,
built on September 19, 2011. Website: F
=head1 LICENSE
Copyrights 2004,2006-2011 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