musicflower.util.surface_scape_indices

musicflower.util.surface_scape_indices(n, axis=None)[source]

Return i, j, k point indices for triangles spanned between points of a triangular map.

A triangular map of resolution n=4 has n(n+1)/2=10 points (left), which define (n-1)^2=9 triangles (right):

      .                      .
     /0\                    /0\
    .___.                  .___.
   /1\ /2\                /1\2/3\
  .___.___.              .___.___.
 /3\ /4\ /5\            /4\5/6\7/8\
.___.___.___.          .___.___.___.
6   7   8   9

The returned point indices i, j, k define the vertices of these triangles, so for the first/top triangle, we have i[0]=0, j[0]=1, k[0]=2, for the second i[1]=1, j[1]=3, k[1]=4 etc. The order of the triangles and their normal (defined by the order of the vertices) may be different from this example, but the normals are guaranteed to point in the same direction for all triangles. It is assumed that points are given in the top-down order from this example, which is the convention used throughout this package and by the TMap class.

Parameters
  • n (Union[int, ndarray]) – resolution of the triangular map or an array with a triangular map (axis specified which dimension corresponds to the triangular map)

  • axis (Optional[int]) – if n is an array, axis has to be provided to specify the dimension corresponding to the triangular map

Return type

Tuple[ndarray, ndarray, ndarray]

Returns

i, j, k