मुख्य सामग्री पर जाएँ

raygeo.sketch

Sketch constraint solving.

Solves 2D geometric constraint systems for parametric sketching: a set of points is moved so that geometric relationships (horizontal, distance, tangency, ...) hold, using the trust-region-reflective least-squares algorithm. The caller describes the problem as a flat list of PointDef entries and constraint objects (see the raygeo.sketch.constraints submodules) and receives solved positions, per-point constrained (fully-determined) flags, and per-constraint conflict indices.

PointDef​

Definition of one sketch point.

fixed​

fixed: bool

Whether the point is pinned and never moves.

id​

id: int

Unique point id, stable across solves.

x​

x: float

Current X coordinate.

y​

y: float

Current Y coordinate.

Solver​

Trust-region least-squares solver for sketch constraint systems.

conflicting()​

conflicting(threshold: float) -> list[int]

Indices of hard constraints whose residual exceeds threshold at the final positions.

ParameterTypeDescription
thresholdfloat
Returnslist[int]

constrained()​

constrained() -> list[bool]

Per-point fully-constrained flags, aligned with the input point order.

ParameterTypeDescription
Returnslist[bool]

jacobian()​

jacobian() -> list[list[float]]

Dense Jacobian rows of the hard constraints at the current positions, over the state points (non-fixed points touched by any constraint, in input order). For tests and debugging.

ParameterTypeDescription
Returnslist[list[float]]

max_residuals()​

max_residuals() -> list[float]

Maximum absolute residual per hard constraint.

ParameterTypeDescription
Returnslist[float]

nfev()​

nfev() -> int

Residual function evaluations of the last solve.

ParameterTypeDescription
Returnsint

positions()​

positions() -> list[tuple[float, float]]

Final (x, y) positions, aligned with the input point order.

ParameterTypeDescription
Returnslist[tuple[float, float]]

residuals()​

residuals() -> list[float]

All residual values of the hard constraints at the current positions, in constraint order.

ParameterTypeDescription
Returnslist[float]

solve()​

solve(tolerance: float, update_dof: bool) -> bool

Runs the solve. Returns True when all components converged.

ParameterTypeDescription
tolerancefloatCost threshold and ftol of the optimizer.
update_dofboolWhether to re-analyze per-point constrained flags after a successful solve.
Returnsbool

status()​

status() -> int

Termination status of the last solve (>0 means success, mirroring SciPy: 1 gtol, 2 ftol, 3 xtol, 4 both, 0 max_nfev).

ParameterTypeDescription
Returnsint