def triangle_area ( pt1 , pt2 , pt3 ) : a = 0.0 a += pt1 [ 0 ] * pt2 [ 1 ] - pt2 [ 0 ] * pt1 [ 1 ] a += pt2 [ 0 ] * pt3 [ 1 ] - pt3 [ 0 ] * pt2 [ 1 ] a += pt3 [ 0 ] * pt1 [ 1 ] - pt1 [ 0 ] * pt3 [ 1 ] return abs ( a ) / 2
area of triangle cross product in numpy python
r Return the area of a triangle .
def triangle_area(pt1, pt2, pt3):
    r"""Return the area of a triangle.

    Parameters
    ----------
    pt1: (X,Y) ndarray
        Starting vertex of a triangle
    pt2: (X,Y) ndarray
        Second vertex of a triangle
    pt3: (X,Y) ndarray
        Ending vertex of a triangle

    Returns
    -------
    area: float
        Area of the given triangle.

    """
    a = 0.0

    a += pt1[0] * pt2[1] - pt2[0] * pt1[1]
    a += pt2[0] * pt3[1] - pt3[0] * pt2[1]
    a += pt3[0] * pt1[1] - pt1[0] * pt3[1]

    return abs(a) / 2