Constraints
Constraints in SuperDex Physics model interactions and attachments between actors. They are the primary mechanism for coupling degrees of freedom (DoFs) across different entities in a simulation, enabling joints, springs, attachments, and kinematic targets.
Modeling a jointed structure (such as a double pendulum) with constraints is the preferred approach when joints are added or removed at runtime. For a fixed joint structure, prefer an articulated actor instead — it is more efficient and robust.
Mathematical Formulation
Constraints are compliant: they contribute an elastic potential and a dissipation potential to the incremental potential of each implicit stage, rather than enforcing an algebraic condition exactly. The notation below follows the dynamics page: is the generalized configuration, the stage-start configuration, and the stage duration.
Constraint Value
Each constraint defines a constraint value that vanishes when the constraint is satisfied, together with its Jacobian
taken with respect to the degrees of freedom of the involved actors. The
Constraint Types below give for each type; GetDeviation (get_deviation in Python) returns its
current value.
Bilateral constraints (joints, attachments, kinematic targets) have a smooth that may take either sign componentwise. Range constraints instead measure a one-sided violation. Written for a single bounded DoF ,
for bounds , so and the corresponding row of vanish inside the bounds. Each range type below bounds its own scalar measure — a joint angle, a rotation-vector component, a slide offset — in place of . A range constraint is inactive, and contributes nothing, when every component is within its bounds both in the current configuration and at the stage start; the stage-start condition matters because the damping term below differences against .
Target-bearing constraints depend on a prescribed target in addition to the configuration, . The target is fixed data within a stage.
Constraint Rate
The rate of the constraint value is discretized as a stage-local difference,
Two properties follow. First, the difference is taken on itself rather than as , which
makes the discrete dissipation term exactly integrable in and therefore admits an incremental
potential. Second, also differences the target: moving a target between stages
produces a damping force. Use UpdateOldTarget (update_old_target in Python) to reset when teleporting a target, so
that no spurious damping transient is generated.
Incremental Potential
A constraint with stiffness and damping contributes
to the stage incremental potential, corresponding to the elastic potential