plane_with_hole¶
- marxs.visualization.utils.plane_with_hole(outer, inner)[source] [edit on github]¶
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
andinner
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, bothouter
andinner
could list a point close to the y-axis first.
- Returns:
- xyznd.array
stacked
outer
andinner
.- 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], [0, 1, 5], [1, 5, 6], [1, 2, 6], [2, 6, 7], [2, 3, 7], [3, 7, 4], [3, 0, 4]])