← Direction Field Lab
LIVE OBJECTIVE 01

Integrable, as unit as possible

Reading map Start locally
INTERACTIVE FIGURE · SPARSE AUTODIFF IN YOUR BROWSER Integrable, as unit as possible

Change the competing terms, take Newton steps, then open the complete lesson and source.

Open full lab ↗
FIELD VIEWcyan = current · pink = target
live expression ready
energy
curl RMS
unit defect
sparse H nnz
accepted steps0
ENERGY HISTORYbacktracking makes every accepted step descend
RESCALED PERIODIC INTEGRABILITY

A direction field becomes a stripe pattern.

A real potential is awkward across periods and branch points. Instead, store a complex phase ψᵢ at each vertex, convert the target vector field into an edge phase increment ωᵢⱼ, and minimize the mismatch after phase transport.

minψ Σij wijj − exp(iωiji
subject to   ‖ψ‖²M = 1
OPTIMIZATION A · FIELD DESIGNMake a unit direction field as curl-free/geodesic as possible.min ½‖δ‖² + λ/2‖∇(w + δ)‖²
s.t. C(w + δ)=0, ‖wᵢ‖=1

This curved-surface stage chooses the foliation direction. The flat browser demo starts from a supplied field so the second optimization stays legible.

OPTIMIZATION B · REALIZATIONRecover a periodic phase—and allow rescaling where compatibility fails.∇θ ≈ s w⊥   or   (d − iω)ψ ≈ 0

The live solve below uses the sparse connection energy. Global normalization avoids the zero solution; local amplitude can fall near incompatible regions and signal stripe singularities.

How to read it

  1. 1

    Arrows are the requested phase-gradient direction. Stripes should run orthogonal to them.

  2. 2

    Color is a periodic function of arg ψ. No global cut or unwrapped real coordinate is needed.

  3. 3

    Brightness is |ψ|. Dark points are where rescaling makes room for incompatibility or a branch point.

Why this is not “just curl reduction”

Local curl, global periods, periodic phase, and amplitude zeros are different modeling choices. This energy measures edge-wise phase transport and solves a globally normalized sparse eigenproblem; the earlier triangle-circulation penalty acts directly on vertex vectors.

Research extension: alternating s and θ

An explicit rescaling field s can first be optimized so s w⊥ + δ lies near the integrable subspace, then alternated with the periodic phase solve. Keeping these two optimizations visible is useful when moving to geodesic foliations.

PERIODIC PHASE VIEWunsolved field
connection energy
edge mismatch RMS
min |ψ|
iterations0
CONVERGENCElog scale · energy + edge residual
4.0 cells / stripeusable preview · choose 43 × 43 to resolve the pattern

This teaching canvas samples phase on the displayed grid, so coarse/high-frequency combinations alias. The original Stripe Patterns method also develops a nonlinear interpolant for rendering above mesh resolution.

The solver is deliberately small: a sparse connection-Laplacian matvec, gradient step, and mass normalization. The research version replaces this iteration with a sparse generalized eigensolver and adds the explicit s/θ alternation.

BONUS EXPERIMENTPolyCurl coefficient reductionopen ↘

Face frames instead of vertex vectors

Compare frames without choosing an ordering

A 4-RoSy frame is encoded by two tangent vectors α and β. Polynomial coefficients stay unchanged when those directions are permuted or sign-flipped; shared-edge residuals can therefore compare frames more symmetrically.

C₀ = α²β²    C₂ = −(α² + β²)

This compact explorer shows the smooth coefficient mismatch and the edge-projected PolyCurl mismatch. Purple and cyan arrows are the two one-sided frame vectors; their dashed drops and thick arrows show each scalar projection onto the common edge before coefficient reduction. The full TinyAD example adds quotient and barrier residuals and optimizes four variables per face.

Read the complete TinyAD PolyCurl example ↗
smooth coefficients
edge-projected