Commit 378a119de6

378a119de6eab1adf89d6575daa9c7fa8ffb6bdc

parent: 2473ec7ec3

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-22 22:02 UTC

Tie a pop's spine-line vertices; spine edges by the paper's halves

During a pop, the tip's mesh vertices on its spine's line that coincide
in frame n - 1, the open pose and the popped pose are one unknown, so
the halves' coincident fold edges move together (R78). A nested step
keeps as spine only the edges on its line that join the halves split by
the opening and spine lines alone, not by the earlier fold's creases
(R77). Adds the crane's crease pattern and script, whose reverse folds
test both.

Ref #7

Layout: unified · split

Models/crane-cp.fold added +122
@@ -0,0 +1,122 @@
1{
2 "file_spec": 1.2,
3 "file_title": "Crane",
4 "file_author": "Traditional",
5 "file_classes": ["creasePattern"],
6 "vertices_coords": [
7 [0, 0],
8 [0.3244233488215, 0],
9 [0.5, 0],
10 [0.53, 0],
11 [1, 0],
12 [0.5657766197194998, 0.08637240054319142],
13 [0.5, 0.0994561836898891],
14 [0.3244233488215, 0.1343805510323628],
15 [0.5657766197195, 0.1798612132116731],
16 [0.5, 0.20710678118654757],
17 [0.22940194992693141, 0.22940194992693144],
18 [0.6318831931224997, 0.24596778661461022],
19 [0.42387953251132926, 0.2832272486752183],
20 [0, 0.32442334882150003],
21 [0.1343805510323628, 0.3244233488215],
22 [0.6676598128425, 0.3323401871575],
23 [0.5, 0.33408931895950933],
24 [0.3535533905932738, 0.3535533905932738],
25 [0.7540322133853905, 0.36811680687750015],
26 [0.2832272486752183, 0.42387953251132926],
27 [0.820138786788327, 0.4342233802805],
28 [0.9136275994568082, 0.4342233802805001],
29 [1, 0.47],
30 [0, 0.5],
31 [0.0994561836898891, 0.5],
32 [0.20710678118654757, 0.5],
33 [0.33408931895950933, 0.5],
34 [0.5, 0.5],
35 [0.6659106810404907, 0.5],
36 [0.7928932188134524, 0.5],
37 [0.9005438163101109, 0.5],
38 [1, 0.5],
39 [0, 0.53],
40 [0.08637240054319247, 0.5657766197194996],
41 [0.1798612132116731, 0.5657766197195],
42 [0.7167727513247817, 0.5761204674886707],
43 [0.24596778661460936, 0.6318831931224993],
44 [0.5, 0.6659106810404907],
45 [0.3323401871575, 0.6676598128425],
46 [0.8656194489676372, 0.6755766511785],
47 [1, 0.6755766511785],
48 [0.5761204674886707, 0.7167727513247817],
49 [0.3681168068775001, 0.7540322133853905],
50 [0.5, 0.7928932188134524],
51 [0.4342233802805, 0.820138786788327],
52 [0, 0.8599999999975],
53 [0.6755766511785, 0.8656194489676372],
54 [0.05357568053211492, 0.870656865446],
55 [0.023227495346077657, 0.8832274953434976],
56 [0.5, 0.9005438163101109],
57 [0.06614631042960091, 0.901005050631998],
58 [0.09899494936749997, 0.9010050506325],
59 [0.43422338028050017, 0.913627599456808],
60 [0.0989949493680003, 0.9338536895703997],
61 [0.129343134554, 0.9464243194678851],
62 [0.11677250465650095, 0.976772504653923],
63 [0, 1],
64 [0.1400000000025, 1],
65 [0.47, 1],
66 [0.5, 1],
67 [0.6755766511785, 1],
68 [1, 1]
69 ],
70 "edges_vertices": [
71 [0, 1], [0, 7], [0, 10], [0, 13], [0, 14], [1, 2], [1, 7], [2, 3],
72 [2, 6], [3, 4], [3, 5], [4, 5], [4, 8], [4, 11], [4, 15], [4, 18],
73 [4, 20], [4, 21], [4, 22], [5, 6], [5, 8], [6, 7], [6, 9], [7, 9],
74 [7, 10], [7, 12], [8, 9], [8, 11], [9, 12], [9, 16], [10, 14], [10, 17],
75 [11, 15], [11, 16], [12, 16], [12, 17], [13, 14], [13, 23], [14, 19], [14, 24],
76 [14, 25], [15, 18], [15, 27], [16, 27], [17, 19], [17, 27], [18, 20], [18, 28],
77 [19, 25], [19, 26], [20, 21], [20, 29], [21, 22], [21, 30], [22, 31], [23, 24],
78 [23, 32], [24, 25], [24, 33], [25, 26], [25, 34], [26, 27], [26, 36], [27, 28],
79 [27, 37], [27, 38], [28, 29], [28, 35], [29, 30], [29, 35], [29, 39], [30, 31],
80 [30, 39], [31, 40], [32, 33], [32, 45], [33, 34], [33, 48], [34, 36], [34, 47],
81 [35, 39], [35, 41], [36, 38], [36, 50], [37, 41], [37, 42], [37, 43], [38, 42],
82 [38, 51], [39, 40], [39, 46], [39, 61], [40, 61], [41, 43], [41, 46], [42, 44],
83 [42, 53], [43, 44], [43, 46], [43, 49], [44, 52], [44, 54], [45, 48], [45, 56],
84 [46, 49], [46, 60], [46, 61], [47, 48], [47, 50], [47, 56], [48, 56], [49, 52],
85 [49, 59], [50, 51], [50, 56], [51, 53], [51, 56], [52, 55], [52, 58], [53, 54],
86 [53, 56], [54, 55], [54, 56], [55, 56], [55, 57], [56, 57], [57, 58], [58, 59],
87 [59, 60], [60, 61]
88 ],
89 "edges_assignment": [
90 "B", "M", "F", "B", "M", "B", "V", "B",
91 "F", "B", "M", "V", "M", "M", "M", "M",
92 "M", "V", "B", "V", "V", "V", "F", "M",
93 "M", "M", "M", "M", "V", "M", "M", "F",
94 "V", "M", "V", "V", "V", "B", "M", "V",
95 "M", "V", "V", "M", "V", "F", "M", "M",
96 "V", "V", "V", "M", "M", "V", "B", "F",
97 "B", "F", "V", "M", "M", "M", "M", "M",
98 "M", "V", "M", "V", "F", "V", "M", "F",
99 "V", "B", "M", "B", "V", "V", "M", "M",
100 "M", "V", "V", "M", "V", "M", "M", "V",
101 "M", "V", "M", "M", "B", "V", "M", "M",
102 "M", "M", "M", "F", "V", "M", "V", "B",
103 "V", "V", "M", "M", "V", "M", "V", "V",
104 "F", "M", "M", "M", "V", "V", "M", "V",
105 "M", "M", "M", "V", "V", "B", "B", "B",
106 "B", "B"
107 ],
108 "faces_vertices": [
109 [0, 1, 7], [0, 7, 10], [0, 10, 14], [0, 14, 13], [1, 2, 6, 7], [2, 3, 5, 6],
110 [3, 4, 5], [4, 8, 5], [4, 11, 8], [4, 15, 11], [4, 18, 15], [4, 20, 18],
111 [4, 21, 20], [4, 22, 21], [5, 8, 9, 6], [6, 9, 7], [7, 9, 12], [7, 12, 17, 10],
112 [8, 11, 16, 9], [9, 16, 12], [10, 17, 19, 14], [11, 15, 27, 16], [12, 16, 27, 17], [13, 14, 24, 23],
113 [14, 19, 25], [14, 25, 24], [15, 18, 28, 27], [17, 27, 26, 19], [18, 20, 29, 28], [19, 26, 25],
114 [20, 21, 30, 29], [21, 22, 31, 30], [23, 24, 33, 32], [24, 25, 34, 33], [25, 26, 36, 34], [26, 27, 38, 36],
115 [27, 28, 35, 41, 37], [27, 37, 42, 38], [28, 29, 35], [29, 30, 39], [29, 39, 35], [30, 31, 40, 39],
116 [32, 33, 48, 45], [33, 34, 47, 48], [34, 36, 50, 47], [35, 39, 46, 41], [36, 38, 51, 50], [37, 41, 43],
117 [37, 43, 44, 42], [38, 42, 53, 51], [39, 40, 61], [39, 61, 46], [41, 46, 43], [42, 44, 54, 53],
118 [43, 46, 49], [43, 49, 52, 44], [44, 52, 55, 54], [45, 48, 56], [46, 60, 59, 49], [46, 61, 60],
119 [47, 50, 56], [47, 56, 48], [49, 59, 58, 52], [50, 51, 56], [51, 53, 56], [52, 58, 57, 55],
120 [53, 54, 56], [54, 55, 56], [55, 57, 56]
121 ]
122}
Models/crane.foldscript added +219
@@ -0,0 +1,219 @@
1{
2 "creasePattern": "crane-cp.fold",
3 "title": "Crane",
4 "steps": [
5 {
6 "kind": "foldAndUnfold",
7 "instruction": "Valley fold in half along the diagonal, bottom corner to top corner, and unfold.",
8 "creases": [[[1, 0], [0.6676598128425, 0.3323401871575]]],
9 "movingSide": [[0.2, 0.2]],
10 "peakAngles": [180],
11 "viewpoint": {"eye": [0, 0, 1], "up": [1, 1, 0]}
12 },
13 {
14 "kind": "foldAndUnfold",
15 "instruction": "Mountain fold in half, top edge behind the bottom edge, and unfold.",
16 "creases": [[[0, 0.5], [0.0994561836898891, 0.5]]],
17 "movingSide": [[0.5, 0.8]],
18 "peakAngles": [-180]
19 },
20 {
21 "kind": "foldAndUnfold",
22 "instruction": "Mountain fold in half the other way, and unfold.",
23 "creases": [[[0.5, 0], [0.5, 0.0994561836898891]]],
24 "movingSide": [[0.8, 0.5]],
25 "peakAngles": [-180]
26 },
27 {
28 "kind": "fold",
29 "instruction": "Collapse into a preliminary base: bring the left, right and top corners down to the bottom corner along the creases.",
30 "creases": [
31 [[0.5, 0.5], [0.5, 0.33408931895950933]],
32 [[0.5, 0.5], [0.6676598128425, 0.3323401871575]],
33 [[0.5, 0.5], [0.6659106810404907, 0.5]],
34 [[0.5, 0.5], [0.5, 0.6659106810404907]],
35 [[0.5, 0.5], [0.3323401871575, 0.6676598128425]],
36 [[0.5, 0.5], [0.33408931895950933, 0.5]]
37 ],
38 "movingSide": [[0.6, 0.15], [0.9, 0.4], [0.8, 0.8], [0.4, 0.9], [0.15, 0.6]],
39 "angles": [-180, 180, -180, -180, 180, -180]
40 },
41 {
42 "kind": "foldAndUnfold",
43 "instruction": "Valley fold the lower edges of the front flap to the centre line, and unfold.",
44 "creases": [[[0, 0], [0.3244233488215, 0.1343805510323628]], [[0, 0], [0.1343805510323628, 0.3244233488215]]],
45 "movingSide": [[0.4, 0.05], [0.05, 0.4]],
46 "peakAngles": [180, 180]
47 },
48 {
49 "kind": "fold",
50 "technique": "petal",
51 "instruction": "Petal fold: lift the bottom corner of the front flap up along the horizontal crease, folding the sides in along the creases so that they meet at the centre line.",
52 "creases": [
53 [[0.20710678118654757, 0.5], [0.2832272486752183, 0.42387953251132926]],
54 [[0, 0], [0.3244233488215, 0.1343805510323628]],
55 [[0, 0], [0.1343805510323628, 0.3244233488215]],
56 [[1, 0], [0.5657766197195, 0.1798612132116731]],
57 [[0, 1], [0.05357568053211492, 0.870656865446]],
58 [[0.5, 0], [0.5, 0.0994561836898891]],
59 [[0, 0.5], [0.0994561836898891, 0.5]]
60 ],
61 "movingSide": [[0.2, 0.2], [0.4, 0.05], [0.6, 0.05], [0.05, 0.4], [0.05, 0.6]],
62 "angles": [180, -180, -180, -180, -180, 0, 0]
63 },
64 {
65 "kind": "turnOver",
66 "instruction": "Turn over.",
67 "turnOverAxis": "vertical"
68 },
69 {
70 "kind": "foldAndUnfold",
71 "instruction": "Valley fold the lower edges of the front flap to the centre line, and unfold.",
72 "creases": [[[1, 1], [0.8656194489676372, 0.6755766511785]], [[1, 1], [0.6755766511785, 0.8656194489676372]]],
73 "movingSide": [[0.95, 0.6], [0.6, 0.95]],
74 "peakAngles": [180, 180],
75 "repeatOf": 5
76 },
77 {
78 "kind": "fold",
79 "technique": "petal",
80 "instruction": "Petal fold the front flap in the same way.",
81 "creases": [
82 [[0.7928932188134524, 0.5], [0.7167727513247817, 0.5761204674886707]],
83 [[1, 1], [0.8656194489676372, 0.6755766511785]],
84 [[1, 1], [0.6755766511785, 0.8656194489676372]],
85 [[1, 0], [0.820138786788327, 0.4342233802805]],
86 [[0, 1], [0.129343134554, 0.9464243194678851]],
87 [[0.7928932188134524, 0.5], [0.9005438163101109, 0.5]],
88 [[0.5, 0.7928932188134524], [0.5, 0.9005438163101109]]
89 ],
90 "movingSide": [[0.764, 0.764], [0.95, 0.6], [0.95, 0.4], [0.6, 0.95], [0.4, 0.95]],
91 "angles": [180, -180, -180, -180, -180, 0, 0],
92 "repeatOf": 6
93 },
94 {
95 "kind": "fold",
96 "instruction": "Valley fold the lower edges of the front flaps to the centre line.",
97 "creases": [[[1, 1.4680790248804205e-16], [0.9136275994568082, 0.4342233802805001]], [[1.2364632855970192e-15, 0.9999999999999994], [0.11677250465650095, 0.976772504653923]]],
98 "movingSide": [[0.9292893218813452, 0.21213203435596406], [0.21213203435596406, 0.9292893218813452]],
99 "angles": [180, 180]
100 },
101 {
102 "kind": "turnOver",
103 "instruction": "Turn over.",
104 "turnOverAxis": "vertical"
105 },
106 {
107 "kind": "fold",
108 "instruction": "Valley fold the lower edges of the front flaps to the centre line.",
109 "creases": [[[1.2474673343699982e-15, 0.999999999999997], [0.023227495346077657, 0.8832274953434976]], [[0.9999999999999986, 0], [0.5657766197194998, 0.08637240054319142]]],
110 "movingSide": [[0.07071067811865533, 0.7878679656440359], [0.7878679656440359, 0.07071067811865439]],
111 "angles": [180, 180],
112 "repeatOf": 10
113 },
114 {
115 "kind": "fold",
116 "technique": "insideReverse",
117 "instruction": "Inside reverse fold the left flap up between the layers of the body to make the neck.",
118 "creases": [[[0.3323401871576772, 0.6676598128423228], [0.24596778661460936, 0.6318831931224993]], [[0.33234018715767727, 0.6676598128423228], [0.3681168068775001, 0.7540322133853905]]],
119 "movingSide": [[0.04750713856159455, 0.9114388810725069]],
120 "spine": [[0.3323401871576772, 0.6676598128423228], [0.5, 0.5]],
121 "faceOrders": [
122 {"above": [0.02739997397231753, 0.7097510287651243], "below": [0.22461172319262507, 0.8141376916076976]},
123 {"above": [0.02739997397231753, 0.7097510287651243], "below": [0.2576695677700001, 0.8636122523030005]},
124 {"above": [0.02739997397231753, 0.7097510287651243], "below": [0.27864059994287527, 0.9142408025917358]},
125 {"above": [0.02739997397231753, 0.7097510287651243], "below": [0.2902489712348753, 0.9726000260276828]},
126 {"above": [0.08575919740826453, 0.7213594000571243], "below": [0.22461172319262507, 0.8141376916076976]},
127 {"above": [0.08575919740826453, 0.7213594000571243], "below": [0.2576695677700001, 0.8636122523030005]},
128 {"above": [0.08575919740826453, 0.7213594000571243], "below": [0.27864059994287527, 0.9142408025917358]},
129 {"above": [0.08575919740826453, 0.7213594000571243], "below": [0.2902489712348753, 0.9726000260276828]},
130 {"above": [0.13638774769699957, 0.7423304322299994], "below": [0.22461172319262507, 0.8141376916076976]},
131 {"above": [0.13638774769699957, 0.7423304322299994], "below": [0.2576695677700001, 0.8636122523030005]},
132 {"above": [0.13638774769699957, 0.7423304322299994], "below": [0.27864059994287527, 0.9142408025917358]},
133 {"above": [0.13638774769699957, 0.7423304322299994], "below": [0.2902489712348753, 0.9726000260276828]},
134 {"above": [0.18586230839230258, 0.7753882768073743], "below": [0.22461172319262507, 0.8141376916076976]},
135 {"above": [0.18586230839230258, 0.7753882768073743], "below": [0.2576695677700001, 0.8636122523030005]},
136 {"above": [0.18586230839230258, 0.7753882768073743], "below": [0.27864059994287527, 0.9142408025917358]},
137 {"above": [0.18586230839230258, 0.7753882768073743], "below": [0.2902489712348753, 0.9726000260276828]},
138 {"above": [0.007742498448692552, 0.9144091651136659], "below": [0.06599663291183343, 0.9449529134009665]},
139 {"above": [0.007742498448692552, 0.9144091651136659], "below": [0.07611269464066676, 0.9600926696794283]},
140 {"above": [0.007742498448692552, 0.9144091651136659], "below": [0.08203854640350032, 0.974398941373936]},
141 {"above": [0.007742498448692552, 0.9144091651136659], "below": [0.08559083488633366, 0.9922575015513077]},
142 {"above": [0.03990733032057194, 0.9238873053593326], "below": [0.06599663291183343, 0.9449529134009665]},
143 {"above": [0.03990733032057194, 0.9238873053593326], "below": [0.07611269464066676, 0.9600926696794283]},
144 {"above": [0.03990733032057194, 0.9238873053593326], "below": [0.08203854640350032, 0.974398941373936]},
145 {"above": [0.03990733032057194, 0.9238873053593326], "below": [0.08559083488633366, 0.9922575015513077]},
146 {"above": [0.025601058626064193, 0.9179614535964992], "below": [0.06599663291183343, 0.9449529134009665]},
147 {"above": [0.025601058626064193, 0.9179614535964992], "below": [0.07611269464066676, 0.9600926696794283]},
148 {"above": [0.025601058626064193, 0.9179614535964992], "below": [0.08203854640350032, 0.974398941373936]},
149 {"above": [0.025601058626064193, 0.9179614535964992], "below": [0.08559083488633366, 0.9922575015513077]},
150 {"above": [0.05504708659903362, 0.9340033670881661], "below": [0.06599663291183343, 0.9449529134009665]},
151 {"above": [0.05504708659903362, 0.9340033670881661], "below": [0.07611269464066676, 0.9600926696794283]},
152 {"above": [0.05504708659903362, 0.9340033670881661], "below": [0.08203854640350032, 0.974398941373936]},
153 {"above": [0.05504708659903362, 0.9340033670881661], "below": [0.08559083488633366, 0.9922575015513077]}
154 ]
155 },
156 {
157 "kind": "fold",
158 "technique": "insideReverse",
159 "instruction": "Inside reverse fold the right flap up in the same way to make the tail.",
160 "creases": [[[0.6676598128423228, 0.33234018715767727], [0.6318831931224997, 0.24596778661461022]], [[0.6676598128423228, 0.3323401871576773], [0.7540322133853905, 0.36811680687750015]]],
161 "movingSide": [[0.9114388810725114, 0.047507138561601325]],
162 "spine": [[0.6676598128423228, 0.33234018715767727], [0.5, 0.5]],
163 "faceOrders": [
164 {"above": [0.6985922065731666, 0.028790800181063808], "below": [0.8072306754092967, 0.2334856646783334]},
165 {"above": [0.6985922065731666, 0.028790800181063808], "below": [0.8580570000579059, 0.2674467290526667]},
166 {"above": [0.6985922065731666, 0.028790800181063808], "below": [0.9112554620817117, 0.28948225352033335]},
167 {"above": [0.6985922065731666, 0.028790800181063808], "below": [0.971209199818936, 0.3014077934268334]},
168 {"above": [0.7105177464796665, 0.08874453791828818], "below": [0.8072306754092967, 0.2334856646783334]},
169 {"above": [0.7105177464796665, 0.08874453791828818], "below": [0.8580570000579059, 0.2674467290526667]},
170 {"above": [0.7105177464796665, 0.08874453791828818], "below": [0.9112554620817117, 0.28948225352033335]},
171 {"above": [0.7105177464796665, 0.08874453791828818], "below": [0.971209199818936, 0.3014077934268334]},
172 {"above": [0.7325532709473332, 0.14194299994209444], "below": [0.8072306754092967, 0.2334856646783334]},
173 {"above": [0.7325532709473332, 0.14194299994209444], "below": [0.8580570000579059, 0.2674467290526667]},
174 {"above": [0.7325532709473332, 0.14194299994209444], "below": [0.9112554620817117, 0.28948225352033335]},
175 {"above": [0.7325532709473332, 0.14194299994209444], "below": [0.971209199818936, 0.3014077934268334]},
176 {"above": [0.7665143353216667, 0.1927693245907034], "below": [0.8072306754092967, 0.2334856646783334]},
177 {"above": [0.7665143353216667, 0.1927693245907034], "below": [0.8580570000579059, 0.2674467290526667]},
178 {"above": [0.7665143353216667, 0.1927693245907034], "below": [0.9112554620817117, 0.28948225352033335]},
179 {"above": [0.7665143353216667, 0.1927693245907034], "below": [0.971209199818936, 0.3014077934268334]}
180 ],
181 "repeatOf": 13
182 },
183 {
184 "kind": "fold",
185 "technique": "insideReverse",
186 "instruction": "Inside reverse fold the end of the neck down between its layers to make the head.",
187 "creases": [[[0.09899494936402875, 0.901005050632401], [0.06614631042960091, 0.901005050631998]], [[0.098994949367599, 0.901005050635971], [0.0989949493680003, 0.9338536895703997]]],
188 "movingSide": [[0.009899494936399411, 0.9901005050632365]],
189 "spine": [[0.09899494936402875, 0.901005050632401], [0.3323401871575, 0.6676598128425]],
190 "openOn": [[0.3323401871576772, 0.6676598128423228], [0.5, 0.5]],
191 "faceOrders": [
192 {"above": [0.007742498448692552, 0.9144091651136659], "below": [0.06599663291183343, 0.9449529134009665]},
193 {"above": [0.007742498448692552, 0.9144091651136659], "below": [0.07611269464066676, 0.9600926696794283]},
194 {"above": [0.007742498448692552, 0.9144091651136659], "below": [0.08203854640350032, 0.974398941373936]},
195 {"above": [0.007742498448692552, 0.9144091651136659], "below": [0.08559083488633366, 0.9922575015513077]},
196 {"above": [0.03990733032057194, 0.9238873053593326], "below": [0.06599663291183343, 0.9449529134009665]},
197 {"above": [0.03990733032057194, 0.9238873053593326], "below": [0.07611269464066676, 0.9600926696794283]},
198 {"above": [0.03990733032057194, 0.9238873053593326], "below": [0.08203854640350032, 0.974398941373936]},
199 {"above": [0.03990733032057194, 0.9238873053593326], "below": [0.08559083488633366, 0.9922575015513077]},
200 {"above": [0.025601058626064193, 0.9179614535964992], "below": [0.06599663291183343, 0.9449529134009665]},
201 {"above": [0.025601058626064193, 0.9179614535964992], "below": [0.07611269464066676, 0.9600926696794283]},
202 {"above": [0.025601058626064193, 0.9179614535964992], "below": [0.08203854640350032, 0.974398941373936]},
203 {"above": [0.025601058626064193, 0.9179614535964992], "below": [0.08559083488633366, 0.9922575015513077]},
204 {"above": [0.05504708659903362, 0.9340033670881661], "below": [0.06599663291183343, 0.9449529134009665]},
205 {"above": [0.05504708659903362, 0.9340033670881661], "below": [0.07611269464066676, 0.9600926696794283]},
206 {"above": [0.05504708659903362, 0.9340033670881661], "below": [0.08203854640350032, 0.974398941373936]},
207 {"above": [0.05504708659903362, 0.9340033670881661], "below": [0.08559083488633366, 0.9922575015513077]}
208 ]
209 },
210 {
211 "kind": "fold",
212 "instruction": "Fold the wings down, the front one toward you and the back one away, so that they stand out from the body.",
213 "creases": [[[0.32442334882149776, 0], [0.3244233488215, 0.1343805510323628]], [[1, 0.6755766511785026], [0.8656194489676372, 0.6755766511785]]],
214 "movingSide": [[0.10000000000000021, 0.01000000000000014], [0.9899999999999961, 0.8999999999999996]],
215 "angles": [90, 90],
216 "viewpoint": {"eye": [0.141, 0.707, 1], "up": [1, 1, 0]}
217 }
218 ]
219}
Packages/FoldKit/Sources/FoldCompiler/PopCompiler.swift +20 −16
@@ -18,21 +18,22 @@ private let angleSamples = 256
18/// on, with decision 0003's opening. `before` is frame n − 1; `after` is frame n as the step's axes 18/// on, with decision 0003's opening. `before` is frame n − 1; `after` is frame n as the step's axes
19/// place it, carrying the step's record; `file` holds frames 0…n − 1. 19/// place it, carrying the step's record; `file` holds frames 0…n − 1.
20/// 20///
21/// The flap opens on the opening crease: `openOn`, or the named spine crease. Both are folded 21/// The flap opens on the opening crease: `openOn`, or the named spine crease. Both are folded flat.
22/// flat. The paper is cut along every edge on either crease's line in `before`, and, with 22/// The paper is cut along every edge on either crease's line in `before`, and, with `openOn`, along
23/// `openOn`, along the creases of the earlier reverse fold that opened on `openOn` and whose flap 23/// the creases of the earlier reverse fold that opened on `openOn` and whose flap holds this
24/// holds this step's. Of each line, the edges whose faces then fall on different sides are kept, 24/// step's. Of the opening crease's line, the edges whose faces then fall on different sides are
25/// each folded flat or flat; a flat one is a bend line, which bends while the flap is open and is 25/// kept; of the spine's, those whose faces fall on different sides of the two lines alone, the
26/// never creased. The side of the opening crease nearer the viewpoint opens, with the earlier 26/// paper's halves. Each kept edge is folded flat or flat; a flat one is a bend line, which bends
27/// fold's flap: the open axes are a tree grown from the other faces across the kept edges, the 27/// while the flap is open and is never creased. The side of the opening crease nearer the viewpoint
28/// opening crease first and driven from ±180 to ±`openAngle`, the earlier fold's creases and the 28/// opens, with the earlier fold's flap: the open axes are a tree grown from the other faces across
29/// spine solved to keep the paper whole. The pop and close move on a tree cut along those edges and 29/// the kept edges, the opening crease first and driven from ±180 to ±`openAngle`, the earlier
30/// the step's creases, grown from the faces neither the opening nor the step moves, the opening 30/// fold's creases and the spine solved to keep the paper whole. The pop and close move on a tree
31/// crease first. In `popped` the opening crease and the spine's edges in the flap are held as the 31/// cut along those edges and the step's creases, grown from the faces neither the opening nor the
32/// open phase leaves them, the latter reversed, and the other tree axes are solved, starting where 32/// step moves, the opening crease first. In `popped` the opening crease and the spine's edges in
33/// the open phase leaves them or `openAngle / 180` of their way. The close axes drive the opening 33/// the flap are held as the open phase leaves them, the latter reversed, and the other tree axes
34/// crease back to ±180 and solve the rest, as for a rigid step, and must arrive at `after`'s 34/// are solved, starting where the open phase leaves them or `openAngle / 180` of their way. The
35/// coordinates. The record's `spine` holds the kept edges of both lines. 35/// close axes drive the opening crease back to ±180 and solve the rest, as for a rigid step, and
36/// must arrive at `after`'s coordinates. The record's `spine` holds the kept edges of both lines.
36/// 37///
37/// The starting guess can lead the solver to another branch of the vertex's motion. Closing the 38/// The starting guess can lead the solver to another branch of the vertex's motion. Closing the
38/// loops does not catch that: every branch is closed. A branch is caught when the close does not 39/// loops does not catch that: every branch is closed. A branch is caught when the close does not
@@ -89,7 +90,10 @@ public func compilePop(step n: Int, script: ScriptStep, before: FoldFrame, after
89 let sides = regions(cut: Set(openerLine + earlierCreases + spineLine), file, edgeFaces) 90 let sides = regions(cut: Set(openerLine + earlierCreases + spineLine), file, edgeFaces)
90 func across(_ e: Int) -> Bool { sides[edgeFaces[e][0]] != sides[edgeFaces[e][1]] } 91 func across(_ e: Int) -> Bool { sides[edgeFaces[e][0]] != sides[edgeFaces[e][1]] }
91 let openLine = openerLine.filter(across) 92 let openLine = openerLine.filter(across)
92 let spine = spineLine.filter(across) 93 // the spine joins the paper's two halves, split by the two lines alone: an edge on the spine's
94 // line inside the earlier fold's flap can be cut off by its creases yet join layers of one half
95 let halves = regions(cut: Set(openerLine + spineLine), file, edgeFaces)
96 let spine = spineLine.filter { halves[edgeFaces[$0][0]] != halves[edgeFaces[$0][1]] }
93 guard (openLine + spine).allSatisfy({ foldedFlat($0) || abs(before.edgesFoldAngle[$0]) <= angleSnapTolerance }) else { 97 guard (openLine + spine).allSatisfy({ foldedFlat($0) || abs(before.edgesFoldAngle[$0]) <= angleSnapTolerance }) else {
94 throw CompileError.invalidSpine(step: n) 98 throw CompileError.invalidSpine(step: n)
95 } 99 }
Packages/FoldKit/Sources/Folding/Bending.swift +18 −6
@@ -10,7 +10,7 @@ import Synchronization
10/// band) it is slerp(mid, own, w), where own is that slerp, mid = slerp(own, other, ½), other is 10/// band) it is slerp(mid, own, w), where own is that slerp, mid = slerp(own, other, ½), other is
11/// the slerp of the partner face's rotation, and w = weight + (1 − weight)(1 − 4s(1 − s)). At 11/// the slerp of the partner face's rotation, and w = weight + (1 − weight)(1 − 4s(1 − s)). At
12/// `s = 0` and `s = 1` every target is the face's own rotation and the fit is exact, so it 12/// `s = 0` and `s = 1` every target is the face's own rotation and the fit is exact, so it
13/// reproduces both poses. 13/// reproduces both poses. Tied vertices are one unknown, so they move together.
14struct Bending: Sendable { 14struct Bending: Sendable {
15 /// A triangle whose turn is blended toward its partner face's. 15 /// A triangle whose turn is blended toward its partner face's.
16 struct Blend: Sendable { 16 struct Blend: Sendable {
@@ -26,8 +26,10 @@ struct Bending: Sendable {
26 private let turns: [simd_quatd] 26 private let turns: [simd_quatd]
27 /// The blended triangles' faces, partners and weights; the k-th takes target `turns.count + k`. 27 /// The blended triangles' faces, partners and weights; the k-th takes target `turns.count + k`.
28 private let blends: [(face: Int, partner: Int, weight: Double)] 28 private let blends: [(face: Int, partner: Int, weight: Double)]
29 /// The mesh vertices that move, in the solve's row order. 29 /// The mesh vertices that move, in the solve's row order, one per tied group.
30 private let free: [Int] 30 private let free: [Int]
31 /// Per mesh vertex, its row in the solve, or −1 when held.
32 private let rows: [Int]
31 /// Per row and target, the signed sum of the rest edge vectors of that target's triangles at 33 /// Per row and target, the signed sum of the rest edge vectors of that target's triangles at
32 /// the row's vertex; the right-hand side adds each turned by the target at `s`. Targets are the 34 /// the row's vertex; the right-hand side adds each turned by the target at `s`. Targets are the
33 /// FOLD faces, then the blended triangles. 35 /// FOLD faces, then the blended triangles.
@@ -40,8 +42,9 @@ struct Bending: Sendable {
40 /// - first, second: the FOLD vertex positions of two rigid poses. 42 /// - first, second: the FOLD vertex positions of two rigid poses.
41 /// - heldFaces: FOLD faces placed alike in both poses, whose mesh vertices stay put. 43 /// - heldFaces: FOLD faces placed alike in both poses, whose mesh vertices stay put.
42 /// - blends: triangles whose turns blend toward a partner face's. 44 /// - blends: triangles whose turns blend toward a partner face's.
45 /// - ties: groups of mesh vertices solved as one unknown; a group with a held vertex is held.
43 init(mesh: RenderMesh, faces: [[Int]], from first: [SIMD3<Double>], to second: [SIMD3<Double>], 46 init(mesh: RenderMesh, faces: [[Int]], from first: [SIMD3<Double>], to second: [SIMD3<Double>],
44 heldFaces: Set<Int>, blends: [Blend] = []) { 47 heldFaces: Set<Int>, blends: [Blend] = [], ties: [[Int]] = []) {
45 rest = mesh.pose(first) 48 rest = mesh.pose(first)
46 turns = faces.map { corners in 49 turns = faces.map { corners in
47 // one corner triple for both poses, chosen on the flat sheet so ties cannot split 50 // one corner triple for both poses, chosen on the flat sheet so ties cannot split
@@ -59,9 +62,18 @@ struct Bending: Sendable {
59 for (t, (a, b, c)) in mesh.triangles.enumerated() where heldFaces.contains(mesh.faceOf[t]) { 62 for (t, (a, b, c)) in mesh.triangles.enumerated() where heldFaces.contains(mesh.faceOf[t]) {
60 (isHeld[a], isHeld[b], isHeld[c]) = (true, true, true) 63 (isHeld[a], isHeld[b], isHeld[c]) = (true, true, true)
61 } 64 }
62 free = mesh.vertices.indices.filter { !isHeld[$0] } 65 for group in ties where group.contains(where: { isHeld[$0] }) {
66 for v in group { isHeld[v] = true }
67 }
68 var representative = Array(mesh.vertices.indices)
69 for group in ties {
70 for v in group { representative[v] = group[0] }
71 }
72 free = mesh.vertices.indices.filter { !isHeld[$0] && representative[$0] == $0 }
63 var row = Array(repeating: -1, count: mesh.vertices.count) 73 var row = Array(repeating: -1, count: mesh.vertices.count)
64 for (r, v) in free.enumerated() { row[v] = r } 74 for (r, v) in free.enumerated() { row[v] = r }
75 for v in mesh.vertices.indices where !isHeld[v] { row[v] = row[representative[v]] }
76 rows = row
65 77
66 // Σ over triangle edges (i, j) of |x_j − x_i − d_ij|²: the normal matrix is the edge 78 // Σ over triangle edges (i, j) of |x_j − x_i − d_ij|²: the normal matrix is the edge
67 // Laplacian; held vertices move to the right-hand side. 79 // Laplacian; held vertices move to the right-hand side.
@@ -69,7 +81,7 @@ struct Bending: Sendable {
69 var sums: [SIMD2<Int>: SIMD3<Double>] = [:] 81 var sums: [SIMD2<Int>: SIMD3<Double>] = [:]
70 var held = Array(repeating: SIMD3<Double>.zero, count: free.count) 82 var held = Array(repeating: SIMD3<Double>.zero, count: free.count)
71 for (t, (a, b, c)) in mesh.triangles.enumerated() { 83 for (t, (a, b, c)) in mesh.triangles.enumerated() {
72 for (i, j) in [(a, b), (b, c), (c, a)] { 84 for (i, j) in [(a, b), (b, c), (c, a)] where row[i] < 0 || row[i] != row[j] {
73 let d = rest[j] - rest[i] 85 let d = rest[j] - rest[i]
74 for (v, other, sign) in [(i, j, -1.0), (j, i, 1.0)] where row[v] >= 0 { 86 for (v, other, sign) in [(i, j, -1.0), (j, i, 1.0)] where row[v] >= 0 {
75 matrix[SIMD2(row[v], row[v]), default: 0] += 1 87 matrix[SIMD2(row[v], row[v]), default: 0] += 1
@@ -111,7 +123,7 @@ struct Bending: Sendable {
111 } 123 }
112 factor.solve(&rhs, columns: 3) 124 factor.solve(&rhs, columns: 3)
113 var result = rest 125 var result = rest
114 for (r, v) in free.enumerated() { result[v] = SIMD3(rhs[r], rhs[n + r], rhs[2 * n + r]) } 126 for (v, r) in rows.enumerated() where r >= 0 { result[v] = SIMD3(rhs[r], rhs[n + r], rhs[2 * n + r]) }
115 return result 127 return result
116 } 128 }
117} 129}
Packages/FoldKit/Sources/Folding/FoldInterpolator.swift +40 −3
@@ -103,10 +103,12 @@ public struct FoldInterpolator: Sendable {
103 let open = Motion(axes: pop.openAxes, kind: .fold, start: start, faces: file.facesVertices) 103 let open = Motion(axes: pop.openAxes, kind: .fold, start: start, faces: file.facesVertices)
104 let close = Motion(axes: pop.closeAxes, kind: .fold, start: pop.popped, faces: file.facesVertices) 104 let close = Motion(axes: pop.closeAxes, kind: .fold, start: pop.popped, faces: file.facesVertices)
105 let moving = step.movingFaceUnion 105 let moving = step.movingFaceUnion
106 let bending = Bending(mesh: mesh, faces: file.facesVertices, 106 let opened = open.positions(at: pop.phases.lowerBound)
107 from: open.positions(at: pop.phases.lowerBound), to: pop.popped, 107 let bending = Bending(mesh: mesh, faces: file.facesVertices, from: opened, to: pop.popped,
108 heldFaces: Set(file.facesVertices.indices.filter { !moving.contains($0) }), 108 heldFaces: Set(file.facesVertices.indices.filter { !moving.contains($0) }),
109 blends: band(mesh: mesh, file: file, tip: moving, spine: pop.spine, start: start)) 109 blends: band(mesh: mesh, file: file, tip: moving, spine: pop.spine, start: start),
110 ties: spineTies(mesh: mesh, file: file, tip: moving, spine: pop.spine, start: start,
111 poses: [opened, pop.popped]))
110 mode = .nonRigid(NonRigid(open: open, close: close, phases: pop.phases, bending: bending)) 112 mode = .nonRigid(NonRigid(open: open, close: close, phases: pop.phases, bending: bending))
111 return 113 return
112 } 114 }
@@ -213,6 +215,41 @@ private func band(mesh: RenderMesh, file: FoldFile, tip: Set<Int>, spine: [Int],
213 } 215 }
214} 216}
215 217
218/// Decision 0003's ruling R78: the tip's mesh vertices on its spine's line in `start` (frame
219/// n − 1), grouped where they coincide in `start` and in every pose of `poses`, so that the
220/// halves' coincident fold edges on that line move together during the pop.
221private func spineTies(mesh: RenderMesh, file: FoldFile, tip: Set<Int>, spine: [Int], start: [SIMD3<Double>],
222 poses: [[SIMD3<Double>]]) -> [[Int]] {
223 let edgeFaces = edgesFaces(file)
224 guard let first = spine.first(where: { edgeFaces[$0].count == 2 && edgeFaces[$0].allSatisfy(tip.contains) })
225 else { return [] }
226 let points = mesh.pose(start)
227 let lower = points.dropFirst().reduce(points[0], simd_min), upper = points.dropFirst().reduce(points[0], simd_max)
228 let tolerance = length(upper - lower) * 1e-9
229 let ends = file.edgesVertices[first].map { start[$0] }
230 let direction = normalize(ends[1] - ends[0])
231 var inTip = Array(repeating: false, count: points.count)
232 for (t, (a, b, c)) in mesh.triangles.enumerated() where tip.contains(mesh.faceOf[t]) {
233 (inTip[a], inTip[b], inTip[c]) = (true, true, true)
234 }
235 let onLine = points.indices.filter { v in
236 let offset = points[v] - ends[0]
237 return inTip[v] && length(offset - dot(offset, direction) * direction) <= tolerance
238 }
239 let placed = poses.map(mesh.pose)
240 var groups: [[Int]] = []
241 for v in onLine {
242 if let g = groups.firstIndex(where: { group in
243 ([points] + placed).allSatisfy { simd_distance($0[group[0]], $0[v]) <= tolerance }
244 }) {
245 groups[g].append(v)
246 } else {
247 groups.append([v])
248 }
249 }
250 return groups.filter { $0.count > 1 }
251}
252
216/// p ↦ linear · p + offset 253/// p ↦ linear · p + offset
217private struct Transform { 254private struct Transform {
218 var linear: simd_double3x3 255 var linear: simd_double3x3
Packages/FoldKit/Tests/ModelsTests/CraneReverseFoldTests.swift added +33
@@ -0,0 +1,33 @@
1import Foundation
2import Testing
3import simd
4import FoldCompiler
5import FoldFormat
6import Folding
7import FoldKitTestSupport
8
9@Test func theCranesReverseFoldsCompile() throws {
10 let crane = try compile(FoldScript(contentsOf: script("crane")), pattern: FoldFile(contentsOf: pattern("crane")))
11
12 // R78: the halves' coincident fold edges on the spine line move together during the pop;
13 // without it step 13's pop passes them through each other
14 for n in 13...15 {
15 let i = FoldInterpolator(file: crane, step: try readStep(n, in: crane))
16 #expect(meshInterpenetrations(i, samples: 64).isEmpty, "step \(n)")
17 }
18
19 // R77: the legs' former edge folds lie on the neck's spine line but join layers of one half;
20 // reversing them breaks frame 15's layer rules
21 let step = try readStep(15, in: crane)
22 let pop = try #require(step.pop)
23 let flat = crane.frames[0].verticesCoords
24 let edgeFaces = edgesFaces(crane)
25 // the halves of the square either side of its diagonal x + y = 1
26 func half(_ f: Int) -> Bool {
27 let sum = crane.facesVertices[f].reduce(SIMD3<Double>.zero) { $0 + flat[$1] }
28 return sum.x + sum.y < Double(crane.facesVertices[f].count)
29 }
30 let tipSpine = pop.spine.filter { edgeFaces[$0].allSatisfy(step.movingFaceUnion.contains) }
31 #expect(!tipSpine.isEmpty)
32 #expect(tipSpine.allSatisfy { half(edgeFaces[$0][0]) != half(edgeFaces[$0][1]) })
33}