resqpy.olio.triangulation.triangulated_polygons

resqpy.olio.triangulation.triangulated_polygons(p, v, centres=None)[source]

Returns triangulation of polygons using centres as extra points.

Parameters:
  • p (2D numpy float array) – points used as vertices of polygons

  • v (list of list of ints) – ordered indices into p for each polygon

  • centres (2D numpy float array, optional) – the points to use as the centre for each polygon

Returns:

points, triangles where – points is a copy of p extended with the centre points of polygons; and triangles is a numpy int array of shape (N, 3) being the triangulation of points, where N is equal to the overall length of v

Notes

if no centres are provided, balanced centre points are computed for the polygons; the polygons must be convex (at least from the perspective of the centre points); the clockwise/anti-clockwise order of the triangle edges will match that of the polygon; the centre point is the first point in each triangle; the order of triangles will match the order of vertices in a flattened view of list v; p and centres may have a shape of 2 or 3 in the second dimension (xy or xyz data); p & v could be the values (c, v) returned by the voronoi() function, in which case the original seed points p passed into voronoi() can be passed as centres here