use strict;
use warnings 'all';
use Data::Dumper;
use Math::Geometry::Planar;
my $outer = Math::Geometry::Planar->new;
my $inner = Math::Geometry::Planar->new;
$outer->points([[0, 0], [0, 3], [3, 3], [3, 0],[0,0]]);
$inner->points([[2, 0], [2, 2], [4, 2], [4, 0],[2,0]]);
my $diff = GpcClip('INTERSECTION', $outer->convert2gpc, $inner->convert2gpc);
#first polygon rep the outer poly, the rest of them are holes
my @pgons = Gpc2Polygons($diff);
#since here we don't have holes, only the first one is a valid polygon
print Dumper($pgons[0]->polygons->[0]);
#convert the points into Planar Polygon
my $result = Math::Geometry::Planar->new;
$result->points($pgons[0]->polygons->[0]);
print Dumper($result);
感谢@ThisSuitlsBlackNot 的帮助。顺便说一句,你有什么想法在多边形内找到一个随机点,这个多边形没有洞。再次感谢