there is no error message but in the console I just see Simple pointInPoly() test...
On 11/6/05, Liam Clarke <[EMAIL PROTECTED]> wrote: > Shi, > > I've just seen 3 queries from you all along the lines of - > > why the following code does not work? > > <code> > > If English is not your first language, I can understand you're not > going to write us a novel. > However, you'll get a better response if you copy and paste the error > message (the traceback) that you're getting in the console. > > Do you know how to copy and paste from the console? > > A lot of us aren't anywhere we can run your code; if we did, it may > work, the error may not be an unhandled exception, just unexpected > behaviour, and we have no idea what behaviour you're expecting. > > So please, in future give us this basic information - > > If there's an error message - copy and paste the error message > If there is no error message - tell us what you expected to happen, > and what happened instead. > > Regards, > > Liam Clarke > On 11/7/05, Shi Mu <[EMAIL PROTECTED]> wrote: > > why the following code does not work? > > > > # determine if a point is inside a given polygon or not > > # Polygon is a list of (x,y) pairs. > > > > def point_inside_polygon(x,y,poly): > > > > n = len(poly) > > inside =False > > > > p1x,p1y = poly[0] > > for i in range(n+1): > > p2x,p2y = poly[i % n] > > if y > min(p1y,p2y): > > if y <= max(p1y,p2y): > > if x <= max(p1x,p2x): > > if p1y != p2y: > > xinters = (y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x > > if p1x == p2x or x <= xinters: > > inside = not inside > > p1x,p1y = p2x,p2y > > > > return inside > > > > if __name__ == '__main__': > > print 'Simple pointInPoly() test...' > > > > poly = [(-1,-1), (6,-1), (5,6), (0,5)] > > point_inside_polygon(3,10,poly) > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor