plane_with_hole

marxs.visualization.utils.plane_with_hole(outer, inner)[source]

Triangulation of a plane with an inner hole

This function constructs a triangulation for a plane with an inner hole, e.g. a rectangular plane where an inner circle is cut out.

Parameters

outer, innernp.ndarray of shape (n, 3)

Coordinates in x,y,z of points that define the inner and outer boundary. outer and inner can have a different number of points, but points need to be listed in the same orientation (e.g. clockwise) for both and the starting points need to have a similar angle as seen from the center (e.g. for a plane with z=0, both outer and inner could list a point close to the y-axis first).

Returns

xyznd.array

stacked outer and inner.

trianglesnd.array

List of the indices. Each row has the index of three points in xyz.

Examples

In this example, we make a square and cut out a smaller square in the middle.

>>> import numpy as np
>>> from marxs.visualization.utils import plane_with_hole
>>> outer = np.array([[-1, -1, 1, 1], [-1, 1, 1, -1], [0, 0, 0, 0]]).T
>>> inner = 0.5 * outer
>>> xyz, triangles = plane_with_hole(outer, inner)
>>> triangles
array([[0, 4, 5],
       [1, 0, 5],
       [1, 5, 6],
       [2, 1, 6],
       [2, 6, 7],
       [3, 2, 7],
       [3, 7, 4],
       [0, 3, 4]])