src/meshzoo/_ngon.py
raw| 1 | import numpy as np |
| 2 | |
| 3 | from ._helpers import _compose_from_faces |
| 4 | |
| 5 | |
| 6 | def ngon(p: int, n: int, offset: float = np.pi / 2): |
| 7 | x = np.linspace(offset, offset + 2 * np.pi, p, endpoint=False) |
| 8 | corners = np.vstack( |
| 9 | [ |
| 10 | [[0.0, 0.0]], |
| 11 | np.array([np.cos(x), np.sin(x)]).T, |
| 12 | ] |
| 13 | ) |
| 14 | faces = [(0, k + 1, k + 2) for k in range(p - 1)] + [(0, p, 1)] |
| 15 | return _compose_from_faces(corners, faces, n) |