def _generate_normals(polygons):
    """
    Takes a list of polygons and return an array of their normals.
    Normals point towards the viewer for a face with its vertices in
    counterclockwise order, following the right hand rule.
    Uses three points equally spaced around the polygon.
    This normal of course might not make sense for polygons with more than
    three points not lying in a plane, but it's a plausible and fast
    approximation.
    Args:
        polygons (list): list of (M_i, 3) array_like, or (..., M, 3) array_like
            A sequence of polygons to compute normals for, which can have
            varying numbers of vertices. If the polygons all have the same
            number of vertices and array is passed, then the operation will
            be vectorized.
    Returns:
        normals: (..., 3) array_like
            A normal vector estimated for the polygon.
    """
    if isinstance(polygons, np.ndarray):
        # optimization: polygons all have the same number of points, so can
        # vectorize
        n = polygons.shape[-2]
        i1, i2, i3 = 0, n//3, 2*n//3
        v1 = polygons[..., i1, :] - polygons[..., i2, :]
        v2 = polygons[..., i2, :] - polygons[..., i3, :]
    else:
        # The subtraction doesn't vectorize because polygons is jagged.
        v1 = np.empty((len(polygons), 3))
        v2 = np.empty((len(polygons), 3))
        for poly_i, ps in enumerate(polygons):
            n = len(ps)
            i1, i2, i3 = 0, n//3, 2*n//3
            v1[poly_i, :] = ps[i1, :] - ps[i2, :]
            v2[poly_i, :] = ps[i2, :] - ps[i3, :]

    return np.cross(v1, v2)
def _generate_normals(polygons):
    """
    Takes a list of polygons and return an array of their normals.
    Normals point towards the viewer for a face with its vertices in
    counterclockwise order, following the right hand rule.
    Uses three points equally spaced around the polygon.
    This normal of course might not make sense for polygons with more than
    three points not lying in a plane, but it's a plausible and fast
    approximation.
    Args:
        polygons (list): list of (M_i, 3) array_like, or (..., M, 3) array_like
            A sequence of polygons to compute normals for, which can have
            varying numbers of vertices. If the polygons all have the same
            number of vertices and array is passed, then the operation will
            be vectorized.
    Returns:
        normals: (..., 3) array_like
            A normal vector estimated for the polygon.
    """
    if isinstance(polygons, np.ndarray):
        # optimization: polygons all have the same number of points, so can
        # vectorize
        n = polygons.shape[-2]
        i1, i2, i3 = 0, n//3, 2*n//3
        v1 = polygons[..., i1, :] - polygons[..., i2, :]
        v2 = polygons[..., i2, :] - polygons[..., i3, :]
    else:
        # The subtraction doesn't vectorize because polygons is jagged.
        v1 = np.empty((len(polygons), 3))
        v2 = np.empty((len(polygons), 3))
        for poly_i, ps in enumerate(polygons):
            n = len(ps)
            i1, i2, i3 = 0, n//3, 2*n//3
            v1[poly_i, :] = ps[i1, :] - ps[i2, :]
            v2[poly_i, :] = ps[i2, :] - ps[i3, :]

    return np.cross(v1, v2)
def _generate_normals ( polygons ) : if isinstance ( polygons , np . ndarray ) : # optimization: polygons all have the same number of points, so can # vectorize n = polygons . shape [ - 2 ] i1 , i2 , i3 = 0 , n // 3 , 2 * n // 3 v1 = polygons [ ... , i1 , : ] - polygons [ ... , i2 , : ] v2 = polygons [ ... , i2 , : ] - polygons [ ... , i3 , : ] else : # The subtraction doesn't vectorize because polygons is jagged. v1 = np . empty ( ( len ( polygons ) , 3 ) ) v2 = np . empty ( ( len ( polygons ) , 3 ) ) for poly_i , ps in enumerate ( polygons ) : n = len ( ps ) i1 , i2 , i3 = 0 , n // 3 , 2 * n // 3 v1 [ poly_i , : ] = ps [ i1 , : ] - ps [ i2 , : ] v2 [ poly_i , : ] = ps [ i2 , : ] - ps [ i3 , : ] return np . cross ( v1 , v2 )
Takes a list of polygons and return an array of their normals.
    Normals point towards the viewer for a face with its vertices in
    counterclockwise order, following the right hand rule.
    Uses three points equally spaced around the polygon.
    This normal of course might not make sense for polygons with more than
    three points not lying in a plane, but it's a plausible and fast
    approximation.
    Args:
        polygons (list): list of (M_i, 3) array_like, or (..., M, 3) array_like
            A sequence of polygons to compute normals for, which can have
            varying numbers of vertices. If the polygons all have the same
            number of vertices and array is passed, then the operation will
            be vectorized.
    Returns:
        normals: (..., 3) array_like
            A normal vector estimated for the polygon.
Takes a list of polygons and return an array of their normals . Normals point towards the viewer for a face with its vertices in counterclockwise order following the right hand rule . Uses three points equally spaced around the polygon . This normal of course might not make sense for polygons with more than three points not lying in a plane but it s a plausible and fast approximation . Args : polygons ( list ) : list of ( M_i 3 ) array_like or ( ... M 3 ) array_like A sequence of polygons to compute normals for which can have varying numbers of vertices . If the polygons all have the same number of vertices and array is passed then the operation will be vectorized . Returns : normals : ( ... 3 ) array_like A normal vector estimated for the polygon .