# # point in polygon test # here I'm using a ray casting algorithm adapted(read perl6-ed) from # the implementation of W. Randolph Franklin: # http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html # my @points = gather for $*IN.get.split(/\s+/) -> $p { take [$p.split(/\,/)] }; my ($x, $y) = $*IN.get.split(/\,/); exit say "invalid input" unless @points > 0 and $x.defined and $y.defined; say ( [+] gather for @points Z @points[1..*-1,0] -> $a, $b { take 1 if ($a[1] > $y xor $b[1] > $y) and ($x < ($b[0]-$a[0]) * ($y-$a[1]) / ($b[1]-$a[1]) + $a[0]) }) % 2 ?? "yes" !! "no"