Index
pleat.shrink_rotate ¶
Shrink-rotate origami crease patterns.
Pipeline overview¶
A shrink-rotate tessellation is built from an input tiling G in three
steps:
- Reciprocal figure — :func:
reciprocal_figuresolves a linear system to place a dual point on each face ofGsuch that the dual edges are perpendicular to the primal edges. These dual points serve as the rotation centers in step 3. - Topological subdivision — the Conway operator
:func:
pleat.conway.shrink_rotate_graphsplits each face into a smaller central polygon plus a ring of quadrilateral twist faces. Twist faces carry a'shrink_rotate'attribute. - Geometric shrink + rotate — each central polygon is rotated by an
angle
alphaand scaled by a factorfactoraround its reciprocal-figure center. With the right parameter pair this is guaranteed to be flat-foldable.
The high-level entry point is :func:shrink_rotate_pattern. Crease
mountain/valley assignment is done by :func:assign_shrink_rotate_creases,
driven by the orientation marks set up via the helpers in
:mod:pleat.shrink_rotate.crease_orientation. An interactive widget for
exploring the parameter space is :class:ShrinkRotateExplorer.
THIS_WAY
module-attribute
¶
Halfedge attribute name marking the upper side of an interior edge (h.face will lie above h.rev.face).
assign_this_way_by_distance ¶
Orient interior edges by distance of face midpoints from point.
The face whose midpoint is farther from point lies below (gets
THIS_WAY). When point is None the centroid of G is used.
Skips already-assigned edges.
Source code in pleat/shrink_rotate/crease_orientation.py
assign_this_way_by_face_area ¶
Orient interior edges by face area.
With larger_on_top (the default), the smaller-area face lies below.
Set larger_on_top=False to invert.
Skips already-assigned edges.
Source code in pleat/shrink_rotate/crease_orientation.py
assign_this_way_by_face_degree ¶
Orient interior edges by face degree (number of incident edges).
With larger_on_top (the default), the smaller-degree face is marked
as lying below. Set larger_on_top=False to invert.
Skips already-assigned edges.
Source code in pleat/shrink_rotate/crease_orientation.py
assign_this_way_by_face_z_order ¶
Use a numeric face attribute key to orient each interior edge.
The halfedge whose face has the larger value of key is left
unmarked; the opposite halfedge gets THIS_WAY (i.e. its face lies
above). Ties are broken using the mean key over the faces incident
to each endpoint.
Skips edges that already have THIS_WAY assigned on either side.
Source code in pleat/shrink_rotate/crease_orientation.py
assign_this_way_by_vertex_z_order ¶
Like :func:assign_this_way_by_face_z_order but keyed on endpoint vertices.
Skips edges that already have THIS_WAY assigned on either side.
Source code in pleat/shrink_rotate/crease_orientation.py
assign_this_way_from_center ¶
Convenience: BFS from the face nearest the geometric centroid of G.
Equivalent to selecting the centermost face and calling
:func:assign_this_way_by_bfs. Skips already-assigned edges.
Source code in pleat/shrink_rotate/crease_orientation.py
clear_this_way ¶
Remove all THIS_WAY marks from halfedges of G.
Call before re-running an assignment from scratch.
assign_shrink_rotate_creases ¶
Set MOUNTAIN/VALLEY creases on a shrink-rotate crease pattern.
The assignment is driven by the
:data:~pleat.shrink_rotate.crease_orientation.THIS_WAY halfedge
marks on the original graph (i.e. on the 'pre_conway' faces of
each twist face): on each interior edge of the original tiling, the
side carrying THIS_WAY indicates which neighbouring face lies above
in the folded model.
For each twist face this routine walks around its boundary in parallel with the corresponding boundary of the original face. Where THIS_WAY marks the original edge, the four halfedges of the corresponding quad in the SRG are assigned MOUNTAIN/VALLEY in a fixed pattern that produces a valid flat fold.
Border halfedges are cleared of any spurious assignment, and each interior edge is made consistent across its two halfedges.
The function expects THIS_WAY to be set externally — see the
helpers in :mod:pleat.shrink_rotate.crease_orientation for ways to
derive it from the geometry of the original tiling.
Source code in pleat/shrink_rotate/pipeline.py
shrink_rotate_pattern ¶
shrink_rotate_pattern(
G: GeometricHEG,
alpha: float = np.pi / 5,
factor: float = 0.5,
*,
assign_creases: bool = True,
simplify_boundary: bool = True,
**reciprocal_figure_kwargs
) -> EuclideanPositionHEG
Build a shrink-rotate crease pattern from tiling G.
Each face of G is subdivided by the shrink-rotate Conway operator; the central polygon of every face is rotated by alpha and scaled by factor around the corresponding reciprocal-figure center.
Parameters¶
G:
Input tiling. If it does not yet have 'reciprocal_pos'
attributes, the reciprocal figure is computed (and cached).
alpha, factor:
Shrink-rotate parameters in radians and as a ratio. The default
alpha=π/5, factor=0.5 is a generic flat-foldable choice.
assign_creases:
When True (the default), additionally call
:func:assign_shrink_rotate_creases, populate 'color_key'
attributes for rendering, and emit a Kawasaki-sum sanity warning.
Set to False to obtain only the bare topology + positions.
simplify_boundary:
When True (and assign_creases is True), remove order-2 vertices
introduced on the boundary by the operator.
**reciprocal_figure_kwargs:
Forwarded to :func:reciprocal_figure if a recomputation is
triggered.
Source code in pleat/shrink_rotate/pipeline.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
reciprocal_figure ¶
reciprocal_figure(
G: GeometricHEG,
reciprocal_pos_key: str = "reciprocal_pos",
rcond: float = 1e-07,
)
Compute the reciprocal figure of G and return it as a face graph.
Stores reciprocal positions on faces of G under
reciprocal_pos_key. Returns the dual graph (one vertex per face of
G, one face per vertex of G) with positioned vertices, mapped
back to G via 'pre' attributes on vertices, halfedges, and
faces.
Source code in pleat/shrink_rotate/reciprocal_figures.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
__getattr__ ¶
Lazily expose :class:ShrinkRotateExplorer (avoids importing matplotlib eagerly).