re point within a polygon in article jonas y gouraud jonas y isy liu se jonas yngvesson writes intersection between a line and a polygon undecidable by dave baraff tom duff from deb charisma graphics cornell edu in recent years many geometric problems have been successfully modeled in a new language called postscript see postscript language by adobe systems incorporated isbn co so given a line l and a polygon p we can write a postscript program that draws the line l and the polygon p and then outputs the answer by output we mean the program executes a command called showpage which actually prints a page of paper containing the line and the polygon a quick examination of the paper provides an answer to the reduced problem q and thus the original problem curiously in modern postscript the point in a polygon problem can be solved even more easily to wit title point in polygon creator allen b ab cc purdue edu for the amusement of comp graphics regulars languagelevel documentneededresource humor sense thereof endcomments this program will test whether a point is inside a given polygon currently it uses the even odd rule but that can be changed by replacing ineofill with infill these are level operators so if you ve only got level you re out of luck the result will be printed on the output stream caution only accurate to device pixels put a huge scale in first if you aren t sure point to test put x and y coordinates here vertices of polygon in counter clockwise order put array of pairs of coordinates here dup get aload pop moveto dup length dup roll sub getinterval aload pop lineto forall closepath ineofill yes no ifelse
