Shapemetry API / Constraint
Type Alias: Constraint
Constraint = {
kind:"coincident";p1:GcsPointHandle;p2:GcsPointHandle; } | {kind:"distance";p1:GcsPointHandle;p2:GcsPointHandle;distance:number; } | {kind:"pointLineDistance";point:GcsPointHandle;line:GcsLineHandle;distance:number; } | {kind:"fixX";point:GcsPointHandle;value:number; } | {kind:"fixY";point:GcsPointHandle;value:number; } | {kind:"horizontal";line:GcsLineHandle; } | {kind:"vertical";line:GcsLineHandle; } | {kind:"angle";line1:GcsLineHandle;line2:GcsLineHandle;angle:number; } | {kind:"perpendicular";line1:GcsLineHandle;line2:GcsLineHandle; } | {kind:"parallel";line1:GcsLineHandle;line2:GcsLineHandle; } | {kind:"pointOnCircle";point:GcsPointHandle;circle:GcsCircleHandle; } | {kind:"pointOnArc";point:GcsPointHandle;arc:GcsArcHandle; } | {kind:"tangentLineArc";line:GcsLineHandle;arc:GcsArcHandle;shared:GcsPointHandle; } | {kind:"tangentArcArc";arc1:GcsArcHandle;arc2:GcsArcHandle;shared:GcsPointHandle; } | {kind:"equalRadiusArcArc";arc1:GcsArcHandle;arc2:GcsArcHandle; } | {kind:"equalRadiusArcCircle";arc:GcsArcHandle;circle:GcsCircleHandle; } | {kind:"arcLength";arc:GcsArcHandle;target:number; } | {kind:"concentricArcArc";arc1:GcsArcHandle;arc2:GcsArcHandle; } | {kind:"concentricArcCircle";arc:GcsArcHandle;circle:GcsCircleHandle; }
Defined in: sketch/constraint.ts:18
All 19 geometric constraint types.
Union Members
Type Literal
{ kind: "coincident"; p1: GcsPointHandle; p2: GcsPointHandle; }
Two points must coincide. 2 residuals: [p1.x - p2.x, p1.y - p2.y].
Type Literal
{ kind: "distance"; p1: GcsPointHandle; p2: GcsPointHandle; distance: number; }
Distance between two points must equal d. 1 residual using squared form: (dx² + dy² - d²) / max(1, 2d).
Type Literal
{ kind: "pointLineDistance"; point: GcsPointHandle; line: GcsLineHandle; distance: number; }
Signed distance from a point to a line must equal d. 1 residual. When d = 0, this is "point on line".
Type Literal
{ kind: "fixX"; point: GcsPointHandle; value: number; }
Fix the X coordinate of a point. 1 residual: p.x - value.
Type Literal
{ kind: "fixY"; point: GcsPointHandle; value: number; }
Fix the Y coordinate of a point. 1 residual: p.y - value.
Type Literal
{ kind: "horizontal"; line: GcsLineHandle; }
A line must be horizontal. 1 residual: p2.y - p1.y.
Type Literal
{ kind: "vertical"; line: GcsLineHandle; }
A line must be vertical. 1 residual: p2.x - p1.x.
Type Literal
{ kind: "angle"; line1: GcsLineHandle; line2: GcsLineHandle; angle: number; }
Angle between two lines in radians. Uses cross-cos form to avoid atan2 discontinuities: cross·cos(θ) - dot·sin(θ).
Type Literal
{ kind: "perpendicular"; line1: GcsLineHandle; line2: GcsLineHandle; }
Two lines must be perpendicular. 1 residual: dot(d1, d2).
Type Literal
{ kind: "parallel"; line1: GcsLineHandle; line2: GcsLineHandle; }
Two lines must be parallel. 1 residual: cross(d1, d2).
Type Literal
{ kind: "pointOnCircle"; point: GcsPointHandle; circle: GcsCircleHandle; }
Point must lie on a circle. 1 residual: dist(pt, center) - radius.
Type Literal
{ kind: "pointOnArc"; point: GcsPointHandle; arc: GcsArcHandle; }
Point must lie on an arc's circle. 1 residual: dist(pt, center) - dist(start, center).
Type Literal
{ kind: "tangentLineArc"; line: GcsLineHandle; arc: GcsArcHandle; shared: GcsPointHandle; }
A line must be tangent to an arc at a shared point. 1 residual: cross(line_dir, arc_tangent) at the shared point.
Type Literal
{ kind: "tangentArcArc"; arc1: GcsArcHandle; arc2: GcsArcHandle; shared: GcsPointHandle; }
Two arcs must be tangent at a shared point. 1 residual: cross(tangent1, tangent2) at the shared point.
Type Literal
{ kind: "equalRadiusArcArc"; arc1: GcsArcHandle; arc2: GcsArcHandle; }
Two arcs must have equal radius. 1 residual: dist(c1, s1) - dist(c2, s2).
Type Literal
{ kind: "equalRadiusArcCircle"; arc: GcsArcHandle; circle: GcsCircleHandle; }
Arc and circle must have equal radius. 1 residual: dist(center_arc, start_arc) - circle_radius.
Type Literal
{ kind: "arcLength"; arc: GcsArcHandle; target: number; }
Arc length must equal a target value. 1 residual: r * theta - target where r = dist(center, start) and theta = |atan2(cross, dot)| of start/end vectors from center.
Type Literal
{ kind: "concentricArcArc"; arc1: GcsArcHandle; arc2: GcsArcHandle; }
Two arcs must be concentric. 2 residuals: [c1.x - c2.x, c1.y - c2.y].
Type Literal
{ kind: "concentricArcCircle"; arc: GcsArcHandle; circle: GcsCircleHandle; }
Arc and circle must be concentric. 2 residuals: [c_arc.x - c_circ.x, c_arc.y - c_circ.y].