I want to understand the logic behind this code. This piece of code is in python and it tells if a triangle lies inside a specific region. "Vertices" contain the three vertices of the triangle and "p" contains all points in the specific region?
def func(vertices, p):
a, b, c = vertices
cross1 = np.cross(b - a, p - a) <= 0
cross2 = np.cross(c - b, p - b) <= 0
cross3 = np.cross(a - c, p - c) <= 0
return ~(cross1 ^ cross2) & ~(cross2 ^ cross3)
I am unable to understand the logic. Please help. Thanks