def get_triangle_areas()

in scale_comparison/metrics.py [0:0]


def get_triangle_areas(triangles: np.ndarray) -> np.ndarray:
    """
    Measure the area of mesh triangles.
    Args:
        triangles: (N, 3, 3) ndarray with dimension 1 representing 3 vertices
    """
    vtr10 = triangles[:, 1] - triangles[:, 0]  # (N, 3)
    vtr20 = triangles[:, 2] - triangles[:, 0]  # (N, 3)
    area = 0.5 * np.linalg.norm(np.abs(np.cross(vtr10, vtr20, axis=1)), axis=1)
    return area