origami-engine 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. origami_engine-0.1.0/LICENSE +201 -0
  2. origami_engine-0.1.0/MANIFEST.in +8 -0
  3. origami_engine-0.1.0/PKG-INFO +375 -0
  4. origami_engine-0.1.0/README.md +342 -0
  5. origami_engine-0.1.0/docs/crease_pattern_plot.png +0 -0
  6. origami_engine-0.1.0/examples/01_evaluate_reference.py +27 -0
  7. origami_engine-0.1.0/examples/02_json_input.py +37 -0
  8. origami_engine-0.1.0/examples/03_inspect_pattern.py +40 -0
  9. origami_engine-0.1.0/examples/04_evaluate_population.py +32 -0
  10. origami_engine-0.1.0/examples/05_plot_pattern.py +36 -0
  11. origami_engine-0.1.0/examples/README.md +17 -0
  12. origami_engine-0.1.0/experiments/TIMELINE.md +67 -0
  13. origami_engine-0.1.0/experiments/prototype_notebooks.zip +0 -0
  14. origami_engine-0.1.0/origami_engine/__init__.py +70 -0
  15. origami_engine-0.1.0/origami_engine/backend.py +24 -0
  16. origami_engine-0.1.0/origami_engine/constants.py +69 -0
  17. origami_engine-0.1.0/origami_engine/dynamics.py +92 -0
  18. origami_engine-0.1.0/origami_engine/evaluation.py +178 -0
  19. origami_engine-0.1.0/origami_engine/example.py +29 -0
  20. origami_engine-0.1.0/origami_engine/geometry.py +120 -0
  21. origami_engine-0.1.0/origami_engine/model.py +209 -0
  22. origami_engine-0.1.0/origami_engine/patterns.py +86 -0
  23. origami_engine-0.1.0/origami_engine/plotting.py +122 -0
  24. origami_engine-0.1.0/origami_engine/render_individual.py +159 -0
  25. origami_engine-0.1.0/origami_engine/schemas/crease_pattern.schema.json +51 -0
  26. origami_engine-0.1.0/origami_engine/serialization.py +124 -0
  27. origami_engine-0.1.0/origami_engine/simulation.py +90 -0
  28. origami_engine-0.1.0/origami_engine/types.py +52 -0
  29. origami_engine-0.1.0/origami_engine.egg-info/PKG-INFO +375 -0
  30. origami_engine-0.1.0/origami_engine.egg-info/SOURCES.txt +35 -0
  31. origami_engine-0.1.0/origami_engine.egg-info/dependency_links.txt +1 -0
  32. origami_engine-0.1.0/origami_engine.egg-info/entry_points.txt +2 -0
  33. origami_engine-0.1.0/origami_engine.egg-info/requires.txt +13 -0
  34. origami_engine-0.1.0/origami_engine.egg-info/top_level.txt +1 -0
  35. origami_engine-0.1.0/pyproject.toml +71 -0
  36. origami_engine-0.1.0/setup.cfg +4 -0
  37. origami_engine-0.1.0/tests/test_evaluation.py +120 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ include origami_engine/schemas/*.json
2
+ include docs/crease_pattern_plot.png
3
+ include examples/*.py
4
+ include examples/README.md
5
+ include experiments/TIMELINE.md
6
+ include experiments/prototype_notebooks.zip
7
+ include LICENSE
8
+ include README.md
@@ -0,0 +1,375 @@
1
+ Metadata-Version: 2.4
2
+ Name: origami-engine
3
+ Version: 0.1.0
4
+ Summary: MuJoCo origami folding simulator
5
+ Author-email: ihsan <ihsanmuhammadkhoirul@students.unnes.ac.id>
6
+ Keywords: origami,crease-pattern,mujoco,folding-simulation
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Classifier: Topic :: Scientific/Engineering :: Visualization
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: jsonschema>=4.18
21
+ Requires-Dist: matplotlib>=3.7
22
+ Requires-Dist: mujoco>=2.3
23
+ Requires-Dist: numpy>=1.24
24
+ Requires-Dist: shapely>=2.0
25
+ Requires-Dist: imageio[ffmpeg]>=2.34
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8; extra == "dev"
28
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
29
+ Requires-Dist: ruff>=0.9; extra == "dev"
30
+ Requires-Dist: mypy>=1.14; extra == "dev"
31
+ Requires-Dist: pre-commit>=3.8; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # MuJoCo Origami Simulator
35
+
36
+ [![CI](https://github.com/ihsan31415/origami-engine/actions/workflows/ci.yml/badge.svg)](https://github.com/ihsan31415/origami-engine/actions/workflows/ci.yml)
37
+ [![Coverage](https://img.shields.io/badge/coverage-pytest--cov-green.svg)](https://github.com/ihsan31415/origami-engine/actions/workflows/ci.yml)
38
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
39
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-red.svg)](LICENSE)
40
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
41
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
42
+ [![Made with MuJoCo](https://img.shields.io/badge/MuJoCo-physics%20engine-orange.svg)](https://mujoco.org/)
43
+
44
+ This project is a Python-based origami folding simulator built around MuJoCo. It reconstructs a crease pattern from 2D line segments, validates the paper topology, generates a MuJoCo model for the folded sheet, applies fold-angle targets, and optionally vibrates the support table to simulate a realistic folding environment. The code is structured as an engineering pipeline rather than a pure toy example: crease patterns are normalized into a canonical format, polygon faces are built from the sheet layout, MuJoCo XML is generated from the resulting pattern, and the net displacement of the paper is measured as a forward-folding fitness signal.
45
+
46
+ ## What this project does
47
+ - Builds a crease network from `p1`, `p2`, and `angle` data
48
+ - Verifies that the crease graph tiles the square sheet without invalid sliver faces
49
+ - Creates a MuJoCo model from the pattern geometry and hinge constraints
50
+ - Drives fold actuators toward target fold angles during simulation
51
+ - Applies a small support-table vibration for dynamic motion
52
+ - Measures the forward displacement of the paper centroid
53
+ - Exports the rendered motion to video for inspection
54
+
55
+ ## Simulation Output
56
+ Below is the physical rendering of the simulation output, demonstrating how the paper layout reacts to active hinge joint torques and support table vibrations:
57
+
58
+ <table>
59
+ <tr>
60
+ <th>Vibrating Table: Amplitude & Frequency</th>
61
+ <th>Fold Crease</th>
62
+ <th>Video Preview</th>
63
+ </tr>
64
+ <tr>
65
+ <td><strong>Lower</strong> amplitude & frequency</td>
66
+ <td>Partial / standard</td>
67
+ <td>
68
+ <video src="https://github.com/user-attachments/assets/15ff98b3-7a72-46c2-9303-e106c88bc71a"
69
+ width="280" controls muted playsinline></video>
70
+ </td>
71
+ </tr>
72
+ <tr>
73
+ <td><strong>High</strong> amplitude & frequency</td>
74
+ <td>Full</td>
75
+ <td>
76
+ <video src="https://github.com/user-attachments/assets/ef7d9808-d0a5-4c6b-b33c-2c6a81e11003"
77
+ width="280" controls muted playsinline></video>
78
+ </td>
79
+ </tr>
80
+ <tr>
81
+ <td><strong>Higher</strong> amplitude & frequency</td>
82
+ <td>Full</td>
83
+ <td>
84
+ <video src="https://github.com/user-attachments/assets/438714c1-f831-43cb-a729-027816fb3ea5"
85
+ width="280" controls muted playsinline></video>
86
+ </td>
87
+ </tr>
88
+ </table>
89
+
90
+
91
+ ## Core modules
92
+ - `origami_engine/constants.py` — shared physical/solver constants
93
+ - `origami_engine/types.py` — `Crease`, `Pattern`, `SimulationResult` domain types
94
+ - `origami_engine/geometry.py` — crease graph / face reconstruction (`build_pattern`)
95
+ - `origami_engine/model.py` — MuJoCo XML generation (`generate_xml`)
96
+ - `origami_engine/dynamics.py` — simulation loop, table vibration, centroids (`run_simulation`, `drive_table`, `paper_centroid`)
97
+ - `origami_engine/serialization.py` — crease normalization and JSON I/O (validated against the packaged JSON Schema via `jsonschema`)
98
+ - `origami_engine/evaluation.py` — fitness-oriented APIs (`evaluate_individual`, `evaluate_population`)
99
+ - `origami_engine/patterns.py` — reusable reference crease patterns
100
+ - `origami_engine/simulation.py` — backward-compatible facade
101
+ - `origami_engine/render_individual.py` — script for rendering a single pattern to an MP4/video report
102
+ - `origami_engine/example.py` — minimal evaluation workflow
103
+ - `tests/test_evaluation.py` — regression checks for evaluation, input validation, and JSON I/O
104
+
105
+ ## Project layout
106
+ ```text
107
+ .
108
+ ├── origami_engine/
109
+ │ ├── __init__.py
110
+ │ ├── backend.py
111
+ │ ├── constants.py
112
+ │ ├── types.py
113
+ │ ├── geometry.py
114
+ │ ├── model.py
115
+ │ ├── dynamics.py
116
+ │ ├── serialization.py
117
+ │ ├── schemas/
118
+ │ │ └── crease_pattern.schema.json
119
+ │ ├── evaluation.py
120
+ │ ├── patterns.py
121
+ │ ├── simulation.py # facade for backward-compatible imports
122
+ │ ├── render_individual.py
123
+ │ └── example.py
124
+ ├── examples/
125
+ │ ├── README.md
126
+ │ ├── 01_evaluate_reference.py
127
+ │ ├── 02_json_input.py
128
+ │ ├── 03_inspect_pattern.py
129
+ │ └── 04_evaluate_population.py
130
+ ├── crease_patterns/
131
+ │ └── reference_miura_4x4.json
132
+ ├── experiments/
133
+ │ ├── TIMELINE.md
134
+ │ └── prototype_notebooks.zip
135
+ ├── tests/
136
+ │ └── test_evaluation.py
137
+ ├── .github/workflows/ci.yml
138
+ ├── ARCHITECTURE.md
139
+ ├── individual_simulation.mp4
140
+ ├── pyproject.toml
141
+ └── README.md
142
+ ```
143
+
144
+ ## Requirements
145
+ Runtime dependencies are declared in `pyproject.toml` (MuJoCo, NumPy, Shapely, imageio, jsonschema) and installed with:
146
+ ```bash
147
+ pip install -e ".[dev]"
148
+ ```
149
+ which also adds `pytest` for running the test suite. The package is importable as `origami_engine` after installation.
150
+
151
+ ## Quick start
152
+ Create a virtual environment and install the package with development dependencies, then run the validation or rendering scripts.
153
+ ```bash
154
+ python -m venv .venv
155
+ . .venv/bin/activate
156
+ pip install -e ".[dev]"
157
+ python -m pytest -q tests
158
+ python origami_engine/render_individual.py
159
+ ```
160
+
161
+ ## Library API
162
+
163
+ ```bash
164
+ pip install -e ".[dev]"
165
+
166
+ python -c "
167
+ from origami_engine import (
168
+ CREASE_SCHEMA,
169
+ Crease,
170
+ build_pattern,
171
+ evaluate_individual,
172
+ evaluate_population,
173
+ load_creases_from_json,
174
+ normalize_creases,
175
+ reference_miura_legacy_creases,
176
+ save_creases_to_json,
177
+ run_simulation,
178
+ paper_centroid,
179
+ )
180
+ "
181
+ ```
182
+
183
+ A machine‑readable JSON Schema describing the crease input format is included at
184
+ `origami_engine/schemas/crease_pattern.schema.json`. It is used by
185
+ `load_creases_from_json` to validate files at load time (invalid files raise
186
+ `ValueError`), and is also exposed as `origami_engine.CREASE_SCHEMA` for
187
+ validation in your own tools before calling the library.
188
+
189
+ ## API Reference
190
+
191
+ ### Domain types
192
+
193
+ | Export | Description |
194
+ |---|---|
195
+ | `Crease` | A single crease segment with `p1`, `p2` (2D points) and `angle` (radians). Negative = Mountain, positive = Valley. |
196
+ | `Pattern` | Validated face/edge graph from `build_pattern()`. Contains `faces`, `edges`, `loop_edges`, `valid`, `reason`, `n_faces`, `n_loops`. |
197
+ | `SimulationResult` | Result of `run_simulation()`: `model`, `data`, `pattern`, `info`, centroids. |
198
+ | `CREASE_SCHEMA` | JSON Schema for validating crease input files. |
199
+
200
+ ### Pattern construction
201
+
202
+ | Export | Description |
203
+ |---|---|
204
+ | `build_pattern(creases)` | Reconstruct polygonal faces and the spanning-tree hinge graph from a crease list. Returns a `Pattern`. |
205
+ | `load_default_creases()` | Load the default reference crease pattern from JSON, with fallback to the built-in Miura-ori. |
206
+ | `load_creases_from_json(path)` | Load and validate creases from a JSON file. |
207
+ | `save_creases_to_json(creases, path)` | Save creases to a JSON file. |
208
+ | `normalize_creases(creases)` | Normalize raw crease inputs (dicts or `Crease` objects) into `Crease` instances. |
209
+ | `reference_miura_legacy_creases()` | Legacy Miura-ori crease list. |
210
+ | `reference_miura_render_creases()` | Render-tuned Miura-ori crease list. |
211
+
212
+ ### Simulation
213
+
214
+ | Export | Description |
215
+ |---|---|
216
+ | `run_simulation(creases, ...)` | Run a MuJoCo simulation from creases and return a `SimulationResult`. |
217
+ | `generate_xml(pattern)` | Generate MuJoCo XML from a validated `Pattern`. |
218
+ | `drive_table(...)` | Apply support-table vibration during simulation. |
219
+ | `paper_centroid(data)` | Compute the paper centroid from MuJoCo data. |
220
+
221
+ ### Evaluation
222
+
223
+ | Export | Description |
224
+ |---|---|
225
+ | `evaluate_individual(creases, ...)` | Score a single crease pattern via forward displacement. |
226
+ | `evaluate_population(creases_list, ...)` | Score a population of crease patterns, optionally in parallel. |
227
+ | `compute_forward_displacement(...)` | Compute forward displacement from simulation data. |
228
+
229
+ ### Visualization
230
+
231
+ | Export | Description |
232
+ |---|---|
233
+ | `plot_pattern(creases, pat=None)` | Plot a crease pattern: Mountain=crimson dashed, Valley=royalblue dash-dot, degree labels, face indices, loop-edge markers, legend. |
234
+
235
+ ### Constants
236
+
237
+ | Export | Description |
238
+ |---|---|
239
+ | `S` | Sheet size (1.0). |
240
+ | `M`, `V` | Canonical Mountain (negative) and Valley (positive) fold angles (±45°). |
241
+ | `MAX_FOLD`, `MIN_FACE_AREA`, `KP`, `KV`, ... | Physical and solver constants. |
242
+
243
+ ### Example: complete workflow
244
+
245
+ ```python
246
+ from origami_engine import load_default_creases, build_pattern, plot_pattern, run_simulation
247
+
248
+ creases = load_default_creases()
249
+ pat = build_pattern(creases)
250
+
251
+ # Visualize
252
+ plot_pattern(creases, pat)
253
+
254
+ # Simulate
255
+ result = run_simulation(creases, duration=8.0)
256
+ print(result.info["n_faces"], "faces simulated")
257
+ ```
258
+
259
+ ## Examples
260
+
261
+ Runnable usage snippets live in the [`examples/`](examples/README.md) folder:
262
+
263
+ ```bash
264
+ python examples/01_evaluate_reference.py
265
+ python examples/02_json_input.py
266
+ python examples/03_inspect_pattern.py
267
+ python examples/04_evaluate_population.py
268
+ python examples/05_plot_pattern.py
269
+ ```
270
+
271
+
272
+ ## Crease pattern visualization
273
+
274
+ View any crease pattern at a glance with `plot_pattern`:
275
+
276
+ ```python
277
+ from origami_engine import build_pattern, load_default_creases, plot_pattern
278
+
279
+ creases = load_default_creases() # default reference pattern
280
+ pat = build_pattern(creases) # validate faces / edges
281
+ plot_pattern(creases, pat) # Mountain=red dashed, Valley=blue dash-dot
282
+ ```
283
+
284
+ `plot_pattern` draws the sheet between `0.0` and `1.0` on both axes, colours
285
+ Mountain folds crimson dashed and Valley folds royalblue dash-dot, labels every
286
+ crease with its fold angle in degrees, places gray face indices at each
287
+ polygon's representative point, marks loop edges with a black `x`, and prints a
288
+ title like `"24 creases | 16 faces | 9 loop edges (x)"`.
289
+
290
+ Run the example script to open the figure interactively:
291
+
292
+ ```bash
293
+ python examples/05_plot_pattern.py
294
+ ```
295
+
296
+ A pre-rendered version of the default reference pattern is included in the
297
+ repository at [`docs/crease_pattern_plot.png`](docs/crease_pattern_plot.png):
298
+
299
+ <p align="center">
300
+ <img src="docs/crease_pattern_plot.png" alt="Crease pattern plot" width="480" style="border:1px solid #d0d0d0; border-radius:8px; box-shadow:0 2px 8px rgba(0,0,0,0.08);" />
301
+ </p>
302
+
303
+ <p align="center"><sub>Default reference crease pattern — 24 creases | 16 faces | 9 loop edges</sub></p>
304
+
305
+ ## Experimental history
306
+
307
+ This repository also preserves the **experimental stage** of the simulator before it was modularized into `origami_engine/`. These are the historical Jupyter notebooks (not part of the runtime package) that were used to develop the fold physics:
308
+
309
+ - [`experiments/TIMELINE.md`](experiments/TIMELINE.md) — phase-by-phase prototyping history (contact optimization, viscoelastic tuning, tear fixes, etc.)
310
+ - [`experiments/prototype_notebooks.zip`](experiments/prototype_notebooks.zip) — the archived notebook bundle (`GEN_1` … `GEN_4`)
311
+
312
+ Unzip the archive and run the notebooks locally:
313
+
314
+ ```bash
315
+ unzip experiments/prototype_notebooks.zip -d experiments/notebooks
316
+ . .venv/bin/activate
317
+ pip install jupyter
318
+ jupyter notebook experiments/notebooks
319
+ ```
320
+
321
+ ## Example crease input
322
+ Crease data is represented as a list of line segments with a start point, end point, and target fold angle. Target angles dictate whether a joint behaves as a **Mountain fold** (negative radians) or a **Valley fold** (positive radians).
323
+
324
+ ```python
325
+ from origami_engine.simulation import Crease
326
+
327
+ creases = [
328
+ Crease((0.2, 0.0), (0.45, 0.25), -0.7853981633974483),
329
+ Crease((0.45, 0.25), (0.2, 0.5), -0.7853981633974483),
330
+ ]
331
+ ```
332
+
333
+ ### Explicit Mountain-Valley Fold Pairing
334
+ Here is an explicit example of a 90-degree Mountain-Valley fold sequence along a shared crease node to create a standard V-shape:
335
+
336
+ ```python
337
+ import numpy as np
338
+ from origami_engine.simulation import Crease
339
+
340
+ crease_sequence = [
341
+ # Crease 1: Mountain Fold (-90 degrees in radians)
342
+ Crease(p1=(0.0, 0.5), p2=(0.5, 0.5), angle=-np.pi / 2),
343
+ # Crease 2: Valley Fold (+90 degrees in radians)
344
+ Crease(p1=(0.5, 0.5), p2=(1.0, 0.5), angle=np.pi / 2),
345
+ ]
346
+ ```
347
+
348
+ The project also supports JSON input with the following schema:
349
+ ```json
350
+ {
351
+ "angle_unit": "degree",
352
+ "creases": [
353
+ { "p1": [0.0, 0.5], "p2": [0.5, 0.5], "angle": -90.0 },
354
+ { "p1": [0.5, 0.5], "p2": [1.0, 0.5], "angle": 90.0 }
355
+ ]
356
+ }
357
+ ```
358
+
359
+ ## Evaluation workflow
360
+ The project exposes a small evaluation API over the MuJoCo simulation:
361
+ ```python
362
+ from origami_engine.evaluation import evaluate_individual
363
+
364
+ score = evaluate_individual(
365
+ creases,
366
+ duration=8.0,
367
+ trajectory=(1.0, 0.0, 0.0),
368
+ fold_duration=3.0,
369
+ )
370
+ print(score)
371
+ ```
372
+ This returns the forward displacement of the paper centroid relative to the requested trajectory direction, measured after the simulated folding run.
373
+
374
+ ## Notes
375
+ The simulator is built around real paper topology and MuJoCo dynamics. It is not just a geometric crease renderer; it creates a physical model that can be evaluated and visualized under controlled fold and vibration conditions. For implementation details and module responsibilities, see [ARCHITECTURE.md](ARCHITECTURE.md).