A headless parametric 2D sketch engine, in the spirit of Fusion's sketch environment.
You build points, lines, circles, arcs, ellipses and splines in code, tie them
together with geometric and dimensional constraints, and a Levenberg–Marquardt
solver moves the geometry until every constraint holds at once. Dimensions are
ordinary editable values, so changing one and re-solving updates the sketch.
- A Fusion-like constraint set: coincidence, tangency, parallel, perpendicular, symmetry, equality and more.
- Degrees-of-freedom and redundancy analysis, conflict detection, and a multi-solution ambiguity probe.
- Trim, extend, break, fillet, chamfer, mirror, pattern and offset on committed geometry.
- Closed-region profile detection with exact areas and hole nesting.
- Export to SVG and PNG — optionally annotated with dimensions and constraint glyphs — plus DXF R12 and lossless JSON.
w := sketch.NewWorld()
s, err := w.CreateSketch(w.XY())
a, b, d := s.CreatePoint(0, 0), s.CreatePoint(18, 2), s.CreatePoint(1, 13)
ab, ad := s.CreateLine(a, b), s.CreateLine(a, d)
s.Fix(a) // ground one corner
s.AddConstraint(sketch.NewHorizontal(ab), sketch.NewVertical(ad))
width := sketch.NewDistance(a, b, 20) // a driving dimension
s.AddConstraint(width)
res, err := s.Solve(ctx) // res.DOF == 0: fully constrained
width.Set(35) // re-solve and the geometry follows
Godepends on r3, units