Skip to main content

MuJoCo Origami Engine

Latest Release CI Python MuJoCo NumPy Shapely
mypy Ruff pytest JSON Schema pre-commit
Last Commit Issues Stars License



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.

What this project does

  • Builds a crease network from p1, p2, and angle data
  • Verifies that the crease graph tiles the square sheet without invalid sliver faces
  • Creates a MuJoCo model from the pattern geometry and hinge constraints
  • Drives fold actuators toward target fold angles during simulation
  • Applies a small support-table vibration for dynamic motion
  • Measures the forward displacement of the paper centroid
  • Exports the rendered motion to video for inspection

Simulation Output

Below is the physical rendering of the simulation output, demonstrating how the paper layout reacts to active hinge joint torques and support table vibrations:

Reference crease pattern

24 creases | 16 faces | 9 loop edges

Reference Crease Pattern
This table shows the default Miura-ori crease pattern used in simulations. The pattern consists of 24 creases that tile a square sheet, forming 16 polygonal faces with 9 loop edges.

Crease Pattern JSON Schema — validates the structure of crease input files (angle units, point coordinates, mountain/valley signs).
reference_miura_4x4.json — the actual crease pattern data in JSON format, containing the p1, p2, and angle values for each of the 24 creases.

Mountain folds are negative angles (creasing "up"), Valley folds are positive angles (creasing "down").
Vibrating Table: Amplitude & Frequency Fold Crease Video Preview
Lower amplitude & frequency Partial / standard
High amplitude & frequency Full
Higher amplitude & frequency Full

This repository is structured as a library for crease pattern simulation and analysis. For full documentation, see the dedicated files below.

Quick start

Install from PyPI

# uv
uv pip install origami-engine

# pip
pip install origami-engine

Install from source

git clone https://github.com/ihsan31415/origami-engine.git
cd origami-engine

# uv
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]"

# pip
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

Validate (source installation)

python -m pytest -q tests
python origami_engine/render_individual.py

For detailed installation steps, environment management, and usage tutorials, see GETTING_STARTED.md.

📖 Documentation

For in-depth information, see the dedicated documentation files:

  • GETTING_STARTED.md — every install method (pip, uv, source, no-venv), quick start, first simulation
  • TUTORIALS.md — step-by-step recipes: inspect a pattern, score it, JSON round-trip, populations, plotting, rendering
  • API_REFERENCE.md — full public API signatures, domain types, and constants
  • ARCHITECTURE.md — module overview, data flow, and design decisions
  • CREASE_FORMAT.md — crease semantics and the JSON input format (validated against the JSON Schema)
  • SIMULATION.md — MuJoCo XML model structure, the step loop, rendering, and the origami-render CLI
  • EVALUATION.md — fitness semantics and sequential/parallel population evaluation
  • TROUBLESHOOTING.md — install, headless, pattern-validity, and simulation-stability issues
  • GLOSSARY.md — domain terminology
  • CONTRIBUTING.md — dev setup, checks, and the PR process
  • examples/ — README.md: what each runnable example script does
  • experiments/ — TIMELINE.md: the archived prototyping notebooks and how they map to the engine

All documentation lives in docs/.

The README provides a brief overview and the simulation output (the eyecatching feature). All technical content is available in the dedicated documentation files.

Core modules (brief)

  • origami_engine/constants.py — shared physical/solver constants
  • origami_engine/types.py — Crease, Pattern, SimulationResult domain types
  • origami_engine/geometry.py — crease graph / face reconstruction (build_pattern)
  • origami_engine/model.py — MuJoCo XML generation (generate_xml)
  • origami_engine/dynamics.py — simulation loop, table vibration, centroids
  • origami_engine/evaluation.py — fitness APIs (evaluate_individual, evaluate_population)
  • origami_engine/patterns.py — reusable reference crease patterns
  • origami_engine/render_individual.py — render to MP4/video report
  • origami_engine/example.py — minimal evaluation workflow

Library API

pip install -e ".[dev]"

python -c "
from origami_engine import (
    CREASE_SCHEMA,
    Crease,
    build_pattern,
    evaluate_individual,
    evaluate_population,
    load_creases_from_json,
    normalize_creases,
    reference_miura_legacy_creases,
    save_creases_to_json,
    run_simulation,
    paper_centroid,
)
"

For the complete API reference, see API_REFERENCE.md.

Metadata

Release files for origami-engine 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for origami-engine 0.1.1
File Size Uploaded Provenance Actions
origami_engine-0.1.1.tar.gz 2.2 MB With provenance Details for origami_engine-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for origami-engine 0.1.1
File Interpreter ABI Platform Actions
origami_engine-0.1.1-py3-none-any.whl Python 3 none any Details for origami_engine-0.1.1-py3-none-any.whl

Total release size: 2.3 MB

Release files / origami_engine-0.1.1.tar.gz

Download URL origami_engine-0.1.1.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
a3b4a38786f22d2b2f8b88ce6dc76b6ad3dad6fd7d75134e5f95751d030fa3e6
BLAKE2b-256 checksum
How to use checksums
b3743cde090cbc64759c549d12620275836f34e8039069257d8fb7e5127741ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / origami_engine-0.1.1-py3-none-any.whl

Download URL origami_engine-0.1.1-py3-none-any.whl
Size 29.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d1741763e38495e30e59d0ec8bd5bea387798e6f791ac4cdeba216b70473bc2
BLAKE2b-256 checksum
How to use checksums
8817d19c11a5e5ffa9f69645ae708c4cc27f2d3071462026dc43366a87a5495e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for origami-engine 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for origami_engine-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page