def is_left(x0, x1, x2):
"""Returns True if x0 is left of the line between x1 and x2,
False otherwise. Ref: https://stackoverflow.com/questions/1560492"""
assert x1.shape == x2.shape == (2,)
matrix = array([x1-x0, x2-x0])
if len(x0.shape) == 2:
matrix = matrix.transpose((1, 2, 0))
return det(matrix) > 0
评论列表
文章目录