#!c:\strawberry\perl\bin\perl.exe -w use diagnostics; use autodie; use Data::Dumper; use Getopt::Long; # We process long commandline options, better to read, longer time to think over it. use Config::Tiny; # simple configurations use Math::Polygon::Calc; use CAD::Calc; use strict; print "huhu\n"; #my $poly = Math::Polygon->new( [0, 0], [3, 2], [2, 3.5], [0.5, 6], [0, 8], [-0.5, 6], [-2, 3.5], [-3, 2], [0, 0]); my @apoly = ( [0, 0], [3, 2], [2, 3.5], [0.5, 6], [0, 8], [-0.5, 6], [-2, 3.5], [-3, 2], [0, 0]); my $bpoly=\@apoly; print "\n"; if (checkforoffset($bpoly,[0,1],0.1)) { print "1,1: drin\n"; } else { print "1,1: draußen\n"; } exit 0; sub checkforoffset { my $pref=shift; my $pt=shift; my $dist=shift; print "checkforoffset called:\n"; print Dumper($pref); for (my $idx=1; $idx < scalar(@$pref); ++$idx) { my $ldist=getdistance($pref->[$idx-1], $pref->[$idx], $pt); print "dist $ldist \n"; if ($dist >= $ldist) { return (1==0); } } return (1==1); } sub getdistance { print "getdistance called:\n"; print Dumper(\@_); my ($p0,$p1,$pt)=shift; print Dumper($p0); print Dumper($p1); print Dumper($pt); my $vx=$p1->[0]-$p0->[0]; my $vy=$p1->[1]-$p0->[0]; print "$vx $vy \n"; return ( abs($vy*$pt->[0] - $vx*$pt->[1] + $p1->[0]*$p0->[1] - $p1->[1]*$p0->[0]) / sqrt($vy**2 + $vx**2) ); }