Sunday, 22 February 2009

Triangle Test in Python

def in_triangle(p,a,b,c):
# pre: a,b,c must be in clockwise order
# post: true if p is in the triangle abc
return right_of(p,a,b) and right_of(p,b,c) and right_of(p,c,a)

No comments: