docs/decisions/0001-interpolation-model.md
263 lines · 17689 bytes
13 symbols in this file
1# 0001 — Interpolation model
2
3**Status:** decided 2026-10-19 — **option A**. Rigid steps use M2 with
4per-axis windows on *t*. Steps with no rigid motion are flagged non-rigid
5and animated by a model Task 0b chooses. Task 0's stop condition was met
6(the crane's reverse folds have no rigid model that matches the fold); this
7choice resolves it.
8
9**Amended by `0002-non-rigid-steps.md`:** the petal fold is rigid; reverse
10folds and sinks are flagged and open, pop, close; inversions (the sampan's)
11and the masu's wall-raising are classified when authored, not flagged in
12advance.
13
14## Question
15
16How does a step's geometry move between its two frames? Specifically, which
17of these covers each kind of step the four v1 models need:
18
19- **M1** — the design as written: disjoint moving sets, each rotated about its
20 crease in the start frame by a linearly interpolated angle.
21- **M2** — a kinematic tree with solved angle curves: an axis may be carried by
22 another moving face, each axis's angle is a function of *t* (possibly on its
23 own window of *t*), and `foldc` solves the curves so every loop of faces
24 around an interior vertex closes.
25- **M3** — decomposition into sub-steps, each M1 or M2, on one drag.
26- **M4** — non-rigid: per-face transforms between solved poses, exact only at
27 the poses.
28
29## Method
30
31`spikes/interpolation` (`swift run -c release --package-path spikes/interpolation`).
32Each case is a crease pattern built in code. Faces are placed by composing
33rotations about creases along a spanning tree of faces; only creases on the
34tree carry an angle, and every other crease's angle is measured from the
35geometry. The **gap** is the largest distance between two copies of one
36vertex placed through different faces: zero when the paper is whole, the size
37of the tear otherwise. M1 prescribes every angle; M2 drives one crease and
38solves the others by damped Gauss–Newton, continued along *t*. Collisions are
39transversal face–face intersections, ignoring coplanar pairs and boundary
40contact.
41
42## Results
43
44| Case | M1 | M2 / other | Collisions |
45|---|---|---|---|
46| 1. Letter fold, both thirds valley, one step | exact (gap 9e-16) | — | flaps meet at 120.2°. Staggered (one flap on *t* 0–0.5, the other on 0.5–1): none |
47| 2. Letter fold, one valley, one mountain | exact | — | none |
48| 3. Flat-foldable degree-4 vertex (60°, 80°, 120°, 100°) | tears: gap 1.08–1.38 on a sheet of side 2 | M2 exact (4e-12). Opposite creases pair up; the pairs follow tan(ρ₁/2) = k·tan(ρ₂/2) with k = cos((α+β)/2) / cos((α−β)/2) = 0.3473: at the driven crease's 45°, 90°, 135° the other pair is at 16.4°, 38.3°, 80.0° | — |
49| 4. Inside reverse fold, two-layer flap, rest of the flap held | — | no rigid motion reaches it with the flap closed (below) | — |
50| 5. Petal fold of a preliminary base | inconclusive (below) | inconclusive | — |
51
52### Sampling a solved curve
53
54`foldc` writes a solved curve as samples. Rebuilding case 3's curves from
55N + 1 samples and measuring the tear between them (sheet of side 2):
56
57| N | linear | cubic Hermite, central-difference tangents |
58|---|---|---|
59| 16 | 1.0e-2 | 1.1e-3 |
60| 32 | 2.5e-3 | 1.2e-4 |
61| 64 | 6.3e-4 | 1.5e-5 |
62| 128 | 1.6e-4 | 1.8e-6 |
63| 256 | 3.9e-5 | 2.3e-7 |
64
65Cubic converges about eight times per halving. 257 samples keep the tear
66under 1e-6 on this sheet; `foldc` checks each curve at four times its sample
67density and refines a curve that does not.
68
69### Case 4 in detail
70
71Sheet 4×2 folded on its spine y = 1; reverse-fold creases from (2, 1) to
72(3, 0) and (3, 2). Body spine and tip spine start at 180°.
73
74- **Flap held closed** (body spine fixed at 180°): the only rigid motion is the
75 tip swinging about the two coincident reverse creases as one closed unit
76 (tip spine stays 180°, the creases go to ∓180°). That ends at the reverse
77 fold's coordinates with the wrong layering — the tip folded over outside,
78 not between the layers. Gap 8e-14.
79- **Flap free, reverse creases driven:** the solver stays on that same motion.
80- **Flap free, tip spine driven through 0:** the whole flap unfolds and refolds
81 the other way (body spine follows the tip spine to −180°). Not a reverse fold.
82- **Two phases:** open the flap completely flat (body and tip spines 180° → 0°),
83 then fold on the reverse-fold branch (tip spine → −180°, body spine and both
84 reverse creases → 180°). Rigid, gap 1e-13. **This is the only rigid path
85 found, and it requires the flap to open fully flat.**
86- **Forced without opening** (M4, body held, tip spine linear 180° → −180°,
87 one reverse crease least-squares): gap 2.0 on a flap 1 high — the paper
88 tears completely.
89- **Partial opening** (body spine opens to φ at mid-fold and closes, tip spine
90 linear, least-squares): gap 1.6 at φ = 150°, 1.16 at 120°, 0.73 at 90°, 0.36
91 at 60°, 0.24 at 30°. A naive schedule; it shows that a partial opening does
92 not make the motion rigid, not the least strain a designed motion could
93 reach.
94
95The vertex is degree 4 with a straight pair (the spine) and a mirror pair
96(the reverse creases). The runs found three families of rigid motion: the
97spine folding as one line, the tip swinging as a closed unit (only with the
98spine at 180°), and the reverse-fold branch from the flat sheet. Every path
99found from the folded flap to the reverse fold passed through the flat
100sheet.
101
102### Case 5 in detail
103
104Superseded by 0002's case 7, which uses the bird base read from Origami
105Simulator's flat crane and finds the petal fold rigid. The pattern below
106included creases the bird base does not have.
107
108The crease pattern is Origami Simulator's `assets/Bases/birdBase.svg`
109(midlines, the diagonal the preliminary base folds, eight 22.5° kite
110creases), made exact, plus the petal hinge between the kite creases' ends.
111That pattern is not the bird base:
112
113- Origami Simulator's file has no petal hinge. Adding the hinge leaves five
114 creases at each kite end, which no flat fold allows. With the inner square
115 added as well, the solver finds a rigid, collision-free motion (gap 1e-15),
116 but tracing points shows the inner layers' corners lifting with the front
117 point. In a petal fold those corners stay down and become the legs.
118- With Origami Simulator's pattern as given, each kite end is a degree-4
119 vertex with the same structure as case 4's: a straight pair (the midline)
120 and a mirror pair (the two kite creases), sectors 112.5° and 67.5°. If the
121 petal fold reverses the outer midline segment there, case 4's result
122 applies; if the side flaps swing as closed units, it is rigid.
123
124Settling this needs a verified bird-base crease pattern with its mountain and
125valley assignment (e.g. from Lang, *Origami Design Secrets*). No published
126FOLD file was found.
127
128### Not measured
129
130- The sampan's last step, turning the model inside out.
131- The masu's wall-raising.
132
133## What this means
134
1351. **M1 is right for independent folds, with one addition:** axes need their
136 own window on *t*. Case 1 shows two flaps of equal reach folding toward
137 each other on one linear parameter always collide; staggering them is
138 clean.
1392. **Coupled vertices need M2's solved curves.** Linear angles tear a
140 degree-4 vertex by more than half the sheet. The angles are not
141 choosable — they follow the tan relation — which is more work for
142 `foldc`, not for the author.
1433. **Reverse folds have no rigid motion that matches how they are folded.**
144 The rigid path unfolds the flap flat and refolds it. On the crane the
145 neck, tail and head flaps are narrowed, several layers deep; unfolding
146 one flat would undo earlier steps' folds on screen. Not measured on the
147 crane's geometry.
1484. **The petal fold is open** pending a verified crease pattern.
1495. **The overlapping-moving-sets rule for `krz:faceOrders_midFold` has no
150 case left.** The problem it addressed is a collision (case 1), which
151 ordering cannot fix and staggering does. A staggered second flap arrives
152 on a stack that is already flat, where the end frame's order and the
153 near-coplanar clusters apply. Its other use, the peak order of a
154 `foldAndUnfold`, is unaffected.
155
156## Exit criterion
157
158The crane's three inside reverse folds are covered only by M3 with the flap
159fully unfolded, or by M4 — met. Per the plan, the choice is the author's.
160
161## Options
162
163**A. Scoped non-rigid steps (recommended).** Rigid steps use M2 with per-axis
164windows. Steps whose technique has no rigid path — inside and outside reverse
165folds, sinks, inversions — are flagged in `krz:step` and animated by a
166designed non-rigid motion: the flap's layers open partway and the tip swings
167through, with faces near the vertex allowed to bend. For those steps the
168isometry gate becomes a stated strain bound, and the interpenetration check
169still applies. This needs:
170
171- a second spike (Task 0b) on a bending model for the reverse fold, to find a
172 strain bound worth promising;
173- the verified bird-base pattern for case 5;
174- the sampan's inversion and the masu's wall-raising as cases.
175
176It also changes `CLAUDE.md`'s rule that an isometry failure is never a
177tolerance to widen, for flagged steps only.
178
179**B. Rigid via unfolding (M3).** Animate a reverse fold as unfold-flat, then
180refold. Exact and isometric, but it does not show how a reverse fold is made,
181and on the crane it unfolds earlier steps on screen.
182
183**C. Don't animate those steps.** The step jumps or crossfades. This breaks
184the anti-goal "a fold that snaps".
185
186**D. Drop the crane.** Replace it with a traditional model without reverse
187folds or sinks. Most traditional animals use reverse folds; the crane is the
188model most people will open the app for.
189
190## Plan changes made for option A
191
192- **Task 0b** (new, before Task 1, batch A2): a model for non-rigid steps and
193 its strain bound, a verified bird base for the petal fold, the sampan's
194 inversion and the masu's wall-raising. Record 0002.
195- **Task 1:** `AxisRecord` gains `parent: Int?` (the axis whose motion carries
196 it), `window: [Double]?` (its span of *t*, default `[0, 1]`) and
197 `angles: [Double]?` (a solved curve, 257 samples over its window; absent
198 means linear). `StepRecord` gains `nonRigid: Bool`; Task 0b adds what a
199 non-rigid step needs beyond the flag.
200- **Task 3:** `FoldAxis` carries the same; `readSteps` builds the tree and
201 rejects a parent cycle or a window outside 0…1.
202- **Task 4:** `positions(at:)` composes rotations down the tree, using each
203 axis's window and curve (cubic Hermite between samples). The isometry
204 sweep adds case 3's vertex, built in code with curves from the closed form.
205- **Task 6:** a staggered letter fold is clean where the simultaneous one
206 collides.
207- **Task 7:** `foldc` solves each coupled step's curves by the spike's method
208 and writes them; the script may name a step's driving crease and give
209 creases windows.
210- **Task 8:** the catalogue's isometry sweep exempts flagged steps, which are
211 held to Task 0b's bound instead.
212- **Task 2:** unchanged. Removing the overlapping-moving-sets rule (point 5
213 above) is a separate decision, still open.
214
215## Appendix: spike output
216
217`swift run -c release --package-path spikes/interpolation`:
218
219```
220## Case 1 — letter fold, both flaps valley
221- M1, one linear parameter: max gap 8.88e-16; first collision at t = 0.668 (120.2°)
222- M1 staggered (left on t 0–0.5, right on 0.5–1): max gap 8.88e-16; first collision none
223## Case 2 — letter fold, left valley, right mountain
224- M1: max gap 8.88e-16; first collision none
225
226## Case 3 — flat-foldable degree-4 vertex, sectors 60°, 80°, 120°, 100°
227- M1, all four angles linear to the assignment with the odd crease at 0°: max gap 1.38e0 on a sheet of side 2
228- M1, all four angles linear to the assignment with the odd crease at 60°: max gap 1.08e0 on a sheet of side 2
229- M2, 140° crease driven 0 → 180, 0° and 260° creases solved, 60° crease measured (seed for 0°: −): max gap 4.19e-12; angles (0°, 60°, 140°, 260°) at t = 0.25: 45.0, -16.4, 45.0, 16.4; 0.5: 90.0, -38.3, 90.0, 38.3; 0.75: 135.0, -80.0, 135.0, 80.0; 1: 180.0, -180.0, 180.0, 180.0
230- M2, 140° crease driven 0 → 180, 0° and 260° creases solved, 60° crease measured (seed for 0°: +): max gap 4.19e-12; angles (0°, 60°, 140°, 260°) at t = 0.25: 45.0, -16.4, 45.0, 16.4; 0.5: 90.0, -38.3, 90.0, 38.3; 0.75: 135.0, -80.0, 135.0, 80.0; 1: 180.0, -180.0, 180.0, 180.0
231- closed form tan(ρ₁/2) = k·tan(ρ₂/2), k = cos((α+β)/2) / cos((α−β)/2) = 0.3473 for α = 60°, β = 80°
232- solved curves sampled at N + 1 points and interpolated, max gap on a sheet of side 2: N = 16: linear 1.0e-2, cubic 1.07e-3; N = 32: linear 2.49e-3, cubic 1.22e-4; N = 64: linear 6.27e-4, cubic 1.49e-5; N = 128: linear 1.57e-4, cubic 1.83e-6; N = 256: linear 3.92e-5, cubic 2.25e-7
233
234## Case 4 — inside reverse fold, 4×2 sheet folded on its spine y = 1
235- start gap 0. Body spine and tip spine start at 180, reverse creases A (upper layer) and B (lower layer) at 0. Angles below are measured from the geometry and unwrapped, so a value past ±180 means a face went through its neighbour at the hinge.
236- (a) body held at 180, B → 180.0, A solved (seed +): max gap 8.06e-14; ranges body 180.0…180.0, tip 180.0…180.0, A -180.0…0, B 0…180.0; end body 180.0, tip 180.0, A -180.0, B 180.0
237- (a) body held at 180, B → 180.0, A solved (seed −): max gap 8.19e-14; ranges body 180.0…180.0, tip 180.0…180.0, A -180.0…0, B 0…180.0; end body 180.0, tip 180.0, A -180.0, B 180.0
238- (b) body free, B → 180.0, body and A solved: max gap 8.19e-14; ranges body 180.0…180.0, tip 180.0…180.0, A -180.0…0, B 0…180.0; end body 180.0, tip 180.0, A -180.0, B 180.0
239- (a) body held at 180, B → -180.0, A solved (seed +): max gap 8.14e-14; ranges body 180.0…180.0, tip 180.0…180.0, A 0…180.0, B -180.0…0; end body 180.0, tip 180.0, A 180.0, B -180.0
240- (a) body held at 180, B → -180.0, A solved (seed −): max gap 6.37e-14; ranges body 180.0…180.0, tip 180.0…180.0, A 0…180.0, B -180.0…0; end body 180.0, tip 180.0, A 180.0, B -180.0
241- (b) body free, B → -180.0, body and A solved: max gap 8.14e-14; ranges body 180.0…180.0, tip 180.0…180.0, A 0…180.0, B -180.0…0; end body 180.0, tip 180.0, A 180.0, B -180.0
242- (c) body free, tip spine driven 180 → −180, body and B solved (seed B +): max gap 9.93e-14; ranges body -180.0…180.0, tip -180.0…180.0, A 0…0, B 0…0; end body -180.0, tip -180.0, A 0, B 0
243- (c) body free, tip spine driven 180 → −180, body and B solved (seed B −): max gap 9.99e-14; ranges body -180.0…180.0, tip -180.0…180.0, A 0…0, B 0…0; end body -180.0, tip -180.0, A 0, B 0
244- (c′) phase 1, tip spine 180 → 0: max gap 10.0e-14; ranges body 0…180.0, tip 0…180.0, A 0…0, B 0…0; end body 0, tip 0, A 0, B 0
245- (c′) phase 2, tip spine 0 → −180 (seed B +): max gap 9.68e-14; ranges body 0…180.0, tip -180.0…0, A 0…180.0, B 0…180.0; end body 180.0, tip -180.0, A 180.0, B 180.0
246- (c′) phase 2, tip spine 0 → −180 (seed B −): max gap 9.96e-14; ranges body -180.0…0, tip -180.0…0, A 0…0, B 0…0; end body -180.0, tip -180.0, A 0, B 0
247- (d) M4, body held at 180, tip spine forced 180 → −180, B least-squares: max gap 2.0e0; ranges body 180.0…180.0, tip -180.0…180.0, A 0…180.0, B 0…180.0; end body 180.0, tip -180.0, A 180.0, B 180.0 (flap height 1)
248- (e) body spine opened to φ at mid-fold, tip spine driven through, B least-squares: φ 180.0° → gap 2.0e0; φ 150.0° → gap 1.6e0; φ 120.0° → gap 1.16e0; φ 90.0° → gap 7.32e-1; φ 60.0° → gap 3.56e-1; φ 30.0° → gap 2.42e-1; φ 10.0° → gap 4.05e-1; φ 0° → gap 4.81e-1
249
250## Case 5 — petal fold of a preliminary base's front flap
251- 20 faces, 26 creases, 14 free on the spanning tree, 4 measured off it; preliminary base start gap 2.48e-16
252- the petal fold's own creases only (hinge driven; 4 of the 4 kite creases on the tree, the rest measured):
253 - kite seed +: max gap 1.1e-15; collision at t = 0.735; hinge 0…180.0; front kites 0…180.0, 0…180.0 → 180.0, 180.0; inner kites -180.0…0, -180.0…0 → -180.0, -180.0; outer midline segments -180.0…-180.0, -180.0…-180.0 → -180.0, -180.0; inner square sides -180.0…0, 0…180.0, 0…180.0, -180.0…0 → -180.0, 180.0, 180.0, -180.0; creases changed: 10; front kite at t = 0.25, 0.5, 0.75: 45.0, 90.0, 135.0
254 - M1, the same end state with every angle linear: max gap 1.11e-15
255 - kite seed −: max gap 1.27e-15; collision none; hinge 0…180.0; front kites -180.0…0, -180.0…0 → -180.0, -180.0; inner kites 0…180.0, 0…180.0 → 180.0, 180.0; outer midline segments -180.0…-180.0, -180.0…-180.0 → -180.0, -180.0; inner square sides -180.0…0, 0…180.0, 0…180.0, -180.0…0 → -180.0, 180.0, 180.0, -180.0; creases changed: 10; front kite at t = 0.25, 0.5, 0.75: -45.0, -90.0, -135.0
256 - M1, the same end state with every angle linear: max gap 1.31e-15
257 - front point (0,0): (1.0, 1.0, 0) → (0.646, 0.646, -0.5) → (0.293, 0.293, 0)
258 - side corner (0.5,0): (1.0, 0.5, 0) → (0.907, 0.657, -0.073) → (0.646, 0.646, 0)
259 - inner corner (1,0): (1.0, 1.0, 0) → (0.646, 0.646, -0.5) → (0.293, 0.293, 0)
260 - hinge end B: (0.793, 0.5, 0) → (0.793, 0.5, 0) → (0.793, 0.5, 0)
261- control, every crease outside the back quadrant free (14 unknowns): max gap 9.57e-16; collision none; hinge 0…180.0; front kites 0…0, 0…0 → 0, 0; inner kites 0…0, 0…0 → 0, 0; outer midline segments -180.0…-180.0, -180.0…-180.0 → -180.0, -180.0; inner square sides -180.0…0, 0…180.0, 0…180.0, -180.0…0 → -180.0, 180.0, 180.0, -180.0; creases changed: 6
262
263```