Demo entry 6336068

trest

   

Submitted by anonymous on Dec 07, 2016 at 04:01
Language: Python. Code size: 292 Bytes.

def in_poly(pt, poly):
	i, j, nvert = 0, len(poly) - 1, len(poly)
	r = False
	while i < nvert:
		if (poly[i].y > pt.y) != (poly[j].y > pt.y) and \
						pt.x < (poly[j].x - poly[i].x) * (pt.y - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x:
			r = not r
		j, i = i, i + 1
	return r

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).