Return a :class:`Path` instance for a unit regular polygon with the given *numVertices* such that the circumscribing circle has radius 1.0, centered at (0, 0).
(cls, numVertices)
| 788 | |
| 789 | @classmethod |
| 790 | def unit_regular_polygon(cls, numVertices): |
| 791 | """ |
| 792 | Return a :class:`Path` instance for a unit regular polygon with the |
| 793 | given *numVertices* such that the circumscribing circle has radius 1.0, |
| 794 | centered at (0, 0). |
| 795 | """ |
| 796 | if numVertices <= 16: |
| 797 | path = cls._unit_regular_polygons.get(numVertices) |
| 798 | else: |
| 799 | path = None |
| 800 | if path is None: |
| 801 | theta = ((2 * np.pi / numVertices) * np.arange(numVertices + 1) |
| 802 | # This initial rotation is to make sure the polygon always |
| 803 | # "points-up". |
| 804 | + np.pi / 2) |
| 805 | verts = np.column_stack((np.cos(theta), np.sin(theta))) |
| 806 | path = cls(verts, closed=True, readonly=True) |
| 807 | if numVertices <= 16: |
| 808 | cls._unit_regular_polygons[numVertices] = path |
| 809 | return path |
| 810 | |
| 811 | _unit_regular_stars = WeakValueDictionary() |
| 812 |