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);
This class provides an Object Oriented interface around Math::Polygon::Calc, Math::Polygon::Clip, and other. Together, these modules provide basic transformations on 2D polygons in pure perl.
WARNING: these computations may show platform dependent rounding differences. These may also originate from compilation options of the Perl version you installed.