2D Geometry
Constraint Solver
Capabilities
A comprehensive constraint solving toolkit with multiple algorithms, intelligent features, and cross-platform bindings.
Algorithms(5)
Damped least-squares with Armijo backtracking. Dense + sparse variant for well-conditioned systems.
Trust-region interpolating steepest descent and Gauss-Newton. 22.7× faster than LM for chains.
Inverse Hessian approximation with strong Wolfe line search + zoom algorithm.
Limited-memory BFGS with two-loop recursion. O(mn) memory. Auto-selected for n≥100 variables.
CSC Jacobian, SpGEMM for Jᵀ·J, Conjugate Gradient with Jacobi preconditioner for large sparse systems.
Features(6)
20 deduction rules. Fully-deducible systems solve instantly without iteration.
Random perturbation restarts. Keeps best solution across all starts for robust convergence.
Union-Find splits independent constraint groups for parallel-friendly solving.
Eliminates Coincident, Horizontal, Vertical, EqualRadius, Concentric, EqualMinorAxes constraints.
Auto-tries all algorithms if primary fails. Ensures maximum solve success rate.
Reuses previous solution as initial guess. Fix variables temporarily for interactive dragging.
Diagnostics(3)
Algebraic + QR rank-based. Detects under/over/full constraint status precisely.
Per-iteration max residual and cost history for debugging solver behavior.
Detects negative radius, zero-length lines, degenerate arcs/ellipses after solving.
Bindings(2)
PyO3/maturin wheel. Full API: entities, constraints, solve, DOF, diagnostics. pip install ready.
solve_sketch() and solve_sketch_v2() JSON APIs. Runs directly in the browser via WebAssembly.
Additional(2)
Full System state snapshots with batch nesting for interactive editing workflows.
Full round-trip via serde. Save/load systems, share configurations across platforms.
Solve Pipeline
The <code>solve_with_config()</code> flow from input to verified result.
solve_with_config(config)Decompose Subsystems
Union-Find splits independent constraint groups — solve each separately for efficiency.
Multi-Start Restart
Random perturbation restarts across multiple attempts. Keeps the best solution found.
Constraint Propagation
20 deduction rules propagate known values. Fully-deducible systems solve instantly.
Parameter Reduction
Eliminates Coincident, Horizontal, Vertical, EqualRadius, Concentric, EqualMinorAxes.
Primary Algorithm
Attempts the configured primary solver (LM, DogLeg, BFGS, L-BFGS, or Sparse CG).
Fallback Chain
If primary fails, auto-tries remaining algorithms in order. Maximum solve success rate.
Return SolveResult
Converged status, max residual, iterations, convergence history, and diagnostics.
Entities & Constraints
10 geometric entity types and 47+ constraints covering points, lines, circles, arcs, ellipses, hyperbolas, and parabolas.
Entity Types
| Entity | Fields | DOF |
|---|---|---|
| Point | x, y, fixed | 2 |
| Line | p1, p2 | 0 (derived) |
| Circle | center, radius, fixed | 1 |
| Arc | center, start, end, radius, fixed | 1 |
| Ellipse | center, focus1, radmin, fixed | 5 |
| Hyperbola | center, focus1, radmin, fixed | 5 |
| Parabola | vertex, focus, fixed | 4 |
DERIVED ENTITY TYPES
Constraints by Category
Documentation
Everything you need to build, test, benchmark, and understand the solver.
Requirements
- RustRust 1.70+ (stable toolchain)
- WASMwasm-pack for WebAssembly builds
- PythonPython 3.8+ with maturin for Python bindings
Build Rust library:
Build WASM package:
Build Python wheel:
Run tests:
Run benchmarks:
API Documentation
First-class APIs in Rust, JavaScript/WASM, and Python with consistent semantics across all bindings.
Download
Complete source with Rust library, WASM bindings, Python bindings, benchmarks, proptests, and interactive WASM demo.
solver-modular-proptest-1.6.zip
Complete distribution package