# Rotor engine architecture and roadmap

## Product thesis

The engine should not begin as a general-purpose Blender clone. Its advantage is a narrower, deeper model: matrices, spectra, phase, coupled layers, inverse reconstruction, and perceptual projections are first-class data. General mesh and animation features can grow around that core.

## Non-negotiable truth layers

1. **Simulation state** — matrices, complex fields, spectral power, phase, polarization, material parameters, and units.
2. **Measurement layer** — virtual instruments, slices, spectra, histograms, error metrics, and conserved quantities.
3. **Observer layer** — CIE observer, temporal integration, adaptation, or other biological/sensor response.
4. **Display layer** — tone mapping, gamut mapping, false colour, monitor encoding, and accessibility transforms.

No downstream view is allowed to overwrite upstream state. Every false-colour or approximate mode must identify itself in the interface.

## Engine modules

| Module | Responsibility | Current state |
|---|---|---|
| Rotor Core | Fourier conjugate groups, energy ranking, exact inverse reconstruction | Implemented and benchmarked |
| Spectrum Core | Wavelength/frequency conversion, SPD storage, CIE projection, coherent scalar interference | Implemented |
| Layer Field | Stack 2D matrices into 3D fields and couple their complex coefficients | Visual prototype |
| Observer Lab | Human/sensor projections and temporal integration | CIE calibrated; temporal model preliminary |
| Scene Graph | Objects, transforms, parameter animation, dependencies, undo/redo | Planned |
| Optics Lab | Spectral direct light, ray intersections, shadows, diffuse materials | Implemented first scene |
| Field Solver | Vector E/H fields, FDTD or FEM back end, boundaries, media | Planned |
| Material System | Complex refractive index, dispersion, absorption, fluorescence | Planned |
| GPU Renderer | WebGPU compute and rendering, tiled volumes, adaptive quality | Planned |
| Proof Gate | Forward → inverse round trip, residual maps, conservation checks | Matrix proof implemented; field gate planned |
| Node Graph | Visual composition of sources, transforms, solvers, observers, and outputs | Planned |
| Scripting/API | Python and TypeScript scene automation, reproducible experiments | Python numerical API implemented |

## Canonical scene data

Every wave source should eventually store:

- coordinate frame and units;
- wavelength/frequency distribution;
- complex vector amplitude or Stokes/Jones representation;
- coherence relationship and phase reference;
- spatial envelope and boundary condition;
- time model and sampling rate;
- provenance, solver version, and numerical tolerance.

A matrix layer stores dimensions, physical extent, scalar/vector/complex channel schema, basis choice, and transform. Couplings between layers are explicit operators rather than decorative strings.

## Development sequence

### Phase 0 — vertical slice (this package)

- standalone interactive field viewer;
- physical / eye / hidden / compare layers;
- official CIE observer data;
- direct-light sphere and block scene with moving shadows and PNG export;
- editable wavelength, power, and phase components;
- coherent/incoherent intensity audit;
- Fourier rotor matrix analysis and exact reconstruction tests.

### Phase 1 — trustworthy 3D data engine

- typed scene graph and save format;
- import CSV, NumPy, image, volume, and sampled spectrum data;
- true stacked matrix volumes with selectable interpolation;
- complex-valued voxel fields;
- camera, slicing, probes, and measurement overlays;
- deterministic project serialization and undo/redo;
- CPU reference solver plus GPU parity tests.

Exit gate: every saved project reopens bit-for-bit where feasible; forward and inverse transforms report bounded residuals.

### Phase 2 — electromagnetic solver

- vector electric and magnetic fields;
- FDTD prototype with absorbing and periodic boundaries;
- material dispersion and absorption;
- polarization, reflection, refraction, diffraction, and interference;
- stability checks based on the Courant condition;
- benchmark scenes against analytic solutions.

Exit gate: convergence and energy-error reports for canonical problems, with CPU/GPU agreement inside declared tolerance.

### Phase 3 — perception and imaging

- CIE 2006 observers, scotopic response, chromatic adaptation, and configurable temporal filters;
- camera spectral-sensitivity imports;
- wavelength-dependent lens and sensor simulation;
- HDR colour management, ICC/OCIO pipeline, and spectral reconstruction diagnostics;
- metamer search and ambiguity visualization.

Exit gate: reference colour patches and spectral fixtures reproduce published tolerances under declared viewing conditions.

### Phase 4 — creation environment

- node graph, timeline, constraints, procedural operators, and parameter sweeps;
- non-destructive modifiers for rotor fields and matrices;
- Python/TypeScript plug-in SDK;
- distributed simulation jobs and cached multiresolution volumes;
- publication-ready still, animation, data, and interactive exports.

## Performance strategy

- use dense arrays for small fields and chunked sparse volumes for large fields;
- maintain an unoptimized CPU reference implementation as the correctness oracle;
- move hot transforms and solvers to WebGPU compute or native GPU kernels;
- use mixed precision only after measuring error against the reference;
- decouple optical carrier frequency from display playback while preserving phase equations;
- stream level-of-detail representations without mutating the source field.

## Testing gates

Every solver or display feature needs at least one test in each applicable category:

1. analytic identity or conservation law;
2. inverse/round-trip reconstruction;
3. published reference fixture;
4. CPU/GPU equivalence;
5. dimensional-units validation;
6. adversarial zero, extreme, and aliasing cases;
7. perceptual-versus-physical separation.

## What “better than Blender” can mean

The realistic target is not more total features. It is superior inspectability for spectral and field work: every picture can be traced to physical state, every projection is labeled, every inverse has a residual, and the same project can move from a matrix to a field to an observer simulation without flattening its information into RGB.
