cherab.imas.math.polygon.calculate_2d_cell_geometryΒΆ

cherab.imas.math.polygon.calculate_2d_cell_geometry(vertices, triangles, cell_to_triangle)ΒΆ

Calculate areas and area centroids of triangulated 2-D cells.

Each polygonal cell is represented by one or more triangles. The centroid is the area-weighted centroid of those triangles.

Parameters:
vertices : (N, 2) ndarray [numpy.float64]ΒΆ

Coordinates of all polygon vertices.

triangles : (M, 3) ndarray [numpy.int32]ΒΆ

Vertex indices of the triangles forming the cells.

cell_to_triangle : (K, 2) ndarray [numpy.int32]ΒΆ

For each cell, the first triangle index and number of triangles.

Returns:

tuple of ndarray – Cell centroids with shape (K, 2) and areas with shape (K,).