constraints.PerpendicularEdgesConstraint

constraints.PerpendicularEdgesConstraint(a1, a2, b1, b2, *, weight=1.0)

Constraint that forces two sketch edges to be perpendicular.

Edges are given by their endpoint parameters. Unlike :class:~cadjoint.constraints.types.perpendicular.PerpendicularConstraint, which operates on 3D direction vectors, this constrains the differences of 2D sketch points via the dot product: dot(a2 - a1, b2 - b1) = 0

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, 0], free=True, name='b1')
b2 = Vector2([0, 1], free=True, name='b2')
constraint = PerpendicularEdgesConstraint(a1, a2, b1, b2)

Methods

Name Description
compute_residual Compute perpendicular-edges residual: dot(a2 - a1, b2 - b1).
dof_reduction Perpendicular-edges constraint adds 1 scalar equation.
get_parameters Return all four endpoints involved in the constraint.

compute_residual

constraints.PerpendicularEdgesConstraint.compute_residual(param_values)

Compute perpendicular-edges residual: dot(a2 - a1, b2 - b1).

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 the edges are perpendicular)

dof_reduction

constraints.PerpendicularEdgesConstraint.dof_reduction()

Perpendicular-edges constraint adds 1 scalar equation.

get_parameters

constraints.PerpendicularEdgesConstraint.get_parameters()

Return all four endpoints involved in the constraint.