(points, polygon, clockwise=True)
return np.all(cross > 0, axis=2)
check points is in convex polygons. may run 2x faster when write in
    cython(don't need to calculate all cross-product between edge and point)
    Args:
        points: [num_points, 2] array.
        polygon: [num_polygon, num_points_of_polygon, 2] array.
        clockwise: bool. indicate polygon is clockwise.
    Returns:
        [num_points, num_polygon] bool array.
check points is in convex polygons. may run 2x faster when write in
    cython(don't need to calculate all cross-product between edge and point)
    Args:
        points: [num_points, 2] array.
        polygon: [num_polygon, num_points_of_polygon, 2] array.
        clockwise: bool. indicate polygon is clockwise.
    Returns:
        [num_points, num_polygon] bool array.
check points is in convex polygons . may run 2x faster when write in cython ( don t need to calculate all cross - product between edge and point ) Args : points : [ num_points 2 ] array . polygon : [ num_polygon num_points_of_polygon 2 ] array . clockwise : bool . indicate polygon is clockwise . Returns : [ num_points num_polygon ] bool array .
def points_in_convex_polygon(points, polygon, clockwise=True):
    """check points is in convex polygons. may run 2x faster when write in
    cython(don't need to calculate all cross-product between edge and point)
    Args:
        points: [num_points, 2] array.
        polygon: [num_polygon, num_points_of_polygon, 2] array.
        clockwise: bool. indicate polygon is clockwise.
    Returns:
        [num_points, num_polygon] bool array.
    """
    # first convert polygon to directed lines
    num_lines = polygon.shape[1]
    polygon_next = polygon[:, [num_lines - 1] + list(range(num_lines - 1)), :]
    if clockwise:
        vec1 = (polygon - polygon_next)[np.newaxis, ...]
    else:
        vec1 = (polygon_next - polygon)[np.newaxis, ...]
    vec2 = polygon[np.newaxis, ...] - points[:, np.newaxis, np.newaxis, :]
    # [num_points, num_polygon, num_points_of_polygon, 2]
    cross = np.cross(vec1, vec2)
    return np.all(cross > 0, axis=2)
def points_in_convex_polygon ( points , polygon , clockwise = True ) : # first convert polygon to directed lines num_lines = polygon . shape [ 1 ] polygon_next = polygon [ : , [ num_lines - 1 ] + list ( range ( num_lines - 1 ) ) , : ] if clockwise : vec1 = ( polygon - polygon_next ) [ np . newaxis , ... ] else : vec1 = ( polygon_next - polygon ) [ np . newaxis , ... ] vec2 = polygon [ np . newaxis , ... ] - points [ : , np . newaxis , np . newaxis , : ] # [num_points, num_polygon, num_points_of_polygon, 2] cross = np . cross ( vec1 , vec2 ) return np . all ( cross > 0 , axis = 2 )