Expand description
2D parametric constraint-based sketch solver.
Work in progress – a parametric CAD sketching tool built on the arael optimization framework. Draw geometry, apply constraints, and the solver keeps everything consistent in real time.
§Entities
Three entity types, each owning its own parameters:
Point– 2D position (x, y)Line– two endpoints p1, p2 (4 params), plus optional horizontal/vertical/length constraintsArc– center, radius, start/end angle (5 params for arcs, 3 for circles where angles are fixed)
Shared geometry (e.g. two lines meeting at a point) is enforced via coincident constraints, not shared references.
§Constraints
Over 40 constraint types including: coincident (point-point, line-line, point-on-line, point-on-arc), parallel, perpendicular, tangent, equal length/radius, distance, horizontal/vertical distance, and more. All constraints are symbolically differentiated at compile time.
§Solving
The Sketch::solve() method runs Levenberg-Marquardt optimization with
drift regularization. Locking: use Param::fixed(value) to pin
individual parameters. The solver skips fixed params entirely.
Re-exports§
pub use symbol_bag::SymbolBag;pub use expr_constraint::ExpressionConstraint;pub use blocker::BlockerReport;pub use blocker::analyze as analyze_blockers;pub use dimensions::*;
Modules§
- blocker
- Blocker analysis for DOF-rejected constraints.
- dimensions
- expr_
constraint - Expression-based constraints for parametric dimensions.
- symbol_
bag - Symbol bag: runtime mapping from user-friendly names to parameter indices and symbolic expressions. Used for parametric equations in dimensions.
Structs§
- Angle
Constraint - Angle
Constraint Sym - Arc
- ArcArc
Parallel - ArcArc
Parallel Sym - ArcConstraints
- ArcConstraints
Sym - ArcLine
Parallel - ArcLine
Parallel Sym - ArcSym
- Axis
DistanceAA CeCe - Axis
DistanceAA CeCe Sym - Axis
DistanceAA CeE - Axis
DistanceAA CeESym - Axis
DistanceAA CeS - Axis
DistanceAA CeSSym - Axis
DistanceAAE Ce - Axis
DistanceAAE CeSym - Axis
DistanceAAEE - Axis
DistanceAAEE Sym - Axis
DistanceAAES - Axis
DistanceAAES Sym - Axis
DistanceAAS Ce - Axis
DistanceAAS CeSym - Axis
DistanceAASE - Axis
DistanceAASE Sym - Axis
DistanceAASS - Axis
DistanceAASS Sym - Axis
Distance ArcCenter L1 - Axis
Distance ArcCenter L2 - Axis
Distance ArcCenter L1Sym - Axis
Distance ArcCenter L2Sym - Axis
Distance ArcCenterP - Axis
Distance ArcCenterP Sym - Axis
Distance ArcEnd L1 - Axis
Distance ArcEnd L2 - Axis
Distance ArcEnd L1Sym - Axis
Distance ArcEnd L2Sym - Axis
Distance ArcEndP - Axis
Distance ArcEndP Sym - Axis
Distance ArcStart L1 - Axis
Distance ArcStart L2 - Axis
Distance ArcStart L1Sym - Axis
Distance ArcStart L2Sym - Axis
Distance ArcStartP - Axis
Distance ArcStartP Sym - Axis
DistanceL L11 - Axis
DistanceL L12 - Axis
DistanceL L21 - Axis
DistanceL L22 - Axis
DistanceL L11Sym - Axis
DistanceL L12Sym - Axis
DistanceL L21Sym - Axis
DistanceL L22Sym - Axis
DistanceL P1 - Axis
DistanceL P2 - Axis
DistanceL P1Sym - Axis
DistanceL P2Sym - Coincident
ArcCenter - Coincident
ArcCenter End - Coincident
ArcCenter EndSym - Coincident
ArcCenter Start - Coincident
ArcCenter Start Sym - Coincident
ArcCenter Sym - Coincident
ArcEnd - Coincident
ArcEnd Center - Coincident
ArcEnd Center Sym - Coincident
ArcEnd End - Coincident
ArcEnd EndSym - Coincident
ArcEnd Start - Coincident
ArcEnd Start Sym - Coincident
ArcEnd Sym - Coincident
ArcStart - Coincident
ArcStart Center - Coincident
ArcStart Center Sym - Coincident
ArcStart End - Coincident
ArcStart EndSym - Coincident
ArcStart Start - Coincident
ArcStart Start Sym - Coincident
ArcStart Sym - CoincidentL
L11 - CoincidentL
L12 - CoincidentL
L21 - CoincidentL
L22 - CoincidentL
L11Sym - CoincidentL
L12Sym - CoincidentL
L21Sym - CoincidentL
L22Sym - CoincidentL
P1 - CoincidentL
P2 - CoincidentL
P1Arc Center - CoincidentL
P1Arc Center Sym - CoincidentL
P1Arc End - CoincidentL
P1Arc EndSym - CoincidentL
P1Arc Start - CoincidentL
P1Arc Start Sym - CoincidentL
P1Sym - CoincidentL
P2Arc Center - CoincidentL
P2Arc Center Sym - CoincidentL
P2Arc End - CoincidentL
P2Arc EndSym - CoincidentL
P2Arc Start - CoincidentL
P2Arc Start Sym - CoincidentL
P2Sym - CoincidentPP
- CoincidentPP
Sym - Collinear
- Collinear
Sym - Concentric
- Concentric
Sym - DistanceAA
CeCe - DistanceAA
CeCe Sym - DistanceAA
CeE - DistanceAA
CeESym - DistanceAA
CeS - DistanceAA
CeSSym - DistanceAAE
Ce - DistanceAAE
CeSym - DistanceAAEE
- DistanceAAEE
Sym - DistanceAAES
- DistanceAAES
Sym - DistanceAAS
Ce - DistanceAAS
CeSym - DistanceAASE
- DistanceAASE
Sym - DistanceAASS
- DistanceAASS
Sym - Distance
ArcCenterL - Distance
ArcCenter L1 - Distance
ArcCenter L2 - Distance
ArcCenter L1Sym - Distance
ArcCenter L2Sym - Distance
ArcCenterL Sym - Distance
ArcCenterP - Distance
ArcCenterP Sym - Distance
ArcEndL - Distance
ArcEnd L1 - Distance
ArcEnd L2 - Distance
ArcEnd L1Sym - Distance
ArcEnd L2Sym - Distance
ArcEndL Sym - Distance
ArcEndP - Distance
ArcEndP Sym - Distance
ArcStartL - Distance
ArcStart L1 - Distance
ArcStart L2 - Distance
ArcStart L1Sym - Distance
ArcStart L2Sym - Distance
ArcStartL Sym - Distance
ArcStartP - Distance
ArcStartP Sym - Distance
Concentric - Distance
Concentric Sym - DistanceL
L11 - DistanceL
L12 - DistanceL
L21 - DistanceL
L22 - DistanceL
L11Sym - DistanceL
L12Sym - DistanceL
L21Sym - DistanceL
L22Sym - DistanceL
P1 - DistanceL
P2 - DistanceL
P1L - DistanceL
P1LSym - DistanceL
P1Sym - DistanceL
P2L - DistanceL
P2LSym - DistanceL
P2Sym - DistancePL
- DistancePL
Sym - DistancePP
- DistancePP
Sym - DofResult
- Result of DOF (degrees of freedom) analysis.
- Drag
Auto Anchor State - Snapshot returned by
Sketch::add_drag_auto_anchorsand consumed bySketch::remove_drag_auto_anchorsto roll auto-anchors back at drag-end. Cloneable so the GUI can also roll anchors back from a serialized clone of the live sketch. - Equal
Length - Equal
Length Sym - Equal
Radius - Equal
Radius Sym - Horizontal
DistancePP - Horizontal
DistancePP Sym - Line
- Line
Constraints - Line
Constraints Sym - Line
P1On Arc - Line
P1On ArcSym - Line
P1On Line - Line
P1On Line Sym - Line
P2On Arc - Line
P2On ArcSym - Line
P2On Line - Line
P2On Line Sym - Line
Style Sym - LineSym
- Midpoint
ArcEnd - Midpoint
ArcEnd Arc - Midpoint
ArcEnd ArcSym - Midpoint
ArcEnd Sym - Midpoint
ArcPoint - Midpoint
ArcPoint Sym - Midpoint
ArcStart - Midpoint
ArcStart Arc - Midpoint
ArcStart ArcSym - Midpoint
ArcStart Sym - Midpoint
Constraint - Midpoint
Constraint Sym - MidpointL
P1 - MidpointL
P2 - MidpointL
P1Arc - MidpointL
P1Arc Sym - MidpointL
P1Sym - MidpointL
P2Arc - MidpointL
P2Arc Sym - MidpointL
P2Sym - Parallel
- Parallel
Sym - Perpendicular
- Perpendicular
Sym - Point
- Point
Constraints - Point
Constraints Sym - Point
OnArc - Point
OnArc Sym - Point
OnLine - Point
OnLine Sym - Point
Sym - Shared
Endpoint Sym - Sketch
- Sketch
Sym - SymmetryAA
- SymmetryAA
Sym - SymmetryLL
- SymmetryLL
Sym - SymmetryPP
- Two points forced symmetric about a mirror line.
Residual: reflect a across line, compare to c.
Dense 3-entity coupling: packed CrossBlocks for each pair beat
TripletBlock’s COO push. hb_ac is unambiguous by type (only
Point-Point pair); the two Point-Line blocks need explicit
cross = (..)to pick their ref. - SymmetryPP
Sym - TangentAA
- TangentAA
Sym - TangentLA
- TangentLA
Sym - Vertical
DistancePP - Vertical
DistancePP Sym
Enums§
- Line
Style - Shared
Endpoint - Which endpoints are shared between two arcs for tangent constraints.
Functions§
- format_
flag_ name - Format a synthetic constraint name for a flag-style constraint on a
named entity. Pattern: “C
”, e.g. “CL0H”, “CL3V”. - parse_
flag_ name - Parse a synthetic constraint name into its entity-name + flag-char
components. Returns None for names that don’t match “C
F” where the first char is ‘C’ and the final char is an uppercase ASCII flag tag (‘H’ or ‘V’ today).