constraints.EqualLengthConstraint
constraints.EqualLengthConstraint(a1, a2, b1, b2, *, weight=1.0)
Constraint that forces two sketch edges to have equal length.
Edges are given by their endpoint parameters. This constraint enforces: ||a1 - a2|| = ||b1 - b2||
Reduces DOF by 1 (one scalar equation).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| a1 | Vector2 | First endpoint of edge A (Vector2 parameter) | required |
| a2 | Vector2 | Second endpoint of edge A (Vector2 parameter) | required |
| b1 | Vector2 | First endpoint of edge B (Vector2 parameter) | required |
| b2 | Vector2 | Second endpoint of edge B (Vector2 parameter) | required |
Example
a1 = Vector2([0, 0], free=True, name='a1')
a2 = Vector2([1, 0], free=True, name='a2')
b1 = Vector2([0, 1], free=True, name='b1')
b2 = Vector2([2, 1], free=True, name='b2')
constraint = EqualLengthConstraint(a1, a2, b1, b2)
Methods
| Name | Description |
|---|---|
| compute_residual | Compute equal-length residual: ||a1 - a2|| - ||b1 - b2||. |
| dof_reduction | Equal-length constraint adds 1 scalar equation. |
| get_parameters | Return all four endpoints involved in the constraint. |
compute_residual
constraints.EqualLengthConstraint.compute_residual(param_values)
Compute equal-length residual: ||a1 - a2|| - ||b1 - b2||.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| param_values | dict[str, Array] | Dict with keys matching parameter names | required |
Returns
| Name | Type | Description |
|---|---|---|
| Array | Scalar residual (0 when constraint is satisfied) |
dof_reduction
constraints.EqualLengthConstraint.dof_reduction()
Equal-length constraint adds 1 scalar equation.
get_parameters
constraints.EqualLengthConstraint.get_parameters()
Return all four endpoints involved in the constraint.