Skip to content

The Guiding Rule: Gauss's Principle of Least Constraint

At the core of Axion's dynamics engine is a beautifully simple and powerful idea from classical mechanics: Gauss's Principle of Least Constraint. This principle provides a single, elegant rule for determining how a system of bodies should move when subjected to constraints (like joints or contacts).

The Core Idea in Simple Terms

Imagine a bead sliding along a bent frictionless wire (the constraint). If you flick the bead, it will try to move in a straight line (unconstrained motion). However, the wire forces it to follow a curve. Gauss's Principle states that at every single moment, the wire will exert the absolute minimum force necessary to keep the bead on its path.

In essence, a constrained system will always accelerate in a way that is "as close as possible" to how it would accelerate if the constraints were not there. This deviation caused by the constraints is what Gauss called the "constraint" and stated that the system moves to make this value as small as possible.

The Formal Principle

Gauss's Principle is formulated as a minimization problem. It states that the true acceleration \(\mathbf{a}\) of a mechanical system is the one that minimizes the following objective function, \(Z\):

\[ Z(\mathbf{a}) = (\mathbf{a} - \mathbf{a_\text{free}})^\top \mathbf{\tilde{M}} (\mathbf{a} - \mathbf{a_\text{free}}) \quad(1) \]

Where:

  • \(\mathbf{a}\) is a possible acceleration of the system that is consistent with the constraints.
  • \(\mathbf{a_\text{free}}\) is the unconstrained acceleration—the acceleration the system would have if only external forces (like gravity) were applied. It is calculated as \(\mathbf{a_\text{free}} = \mathbf{\tilde{M}}^{-1} \mathbf{f_\text{ext}}\).
  • \(\mathbf{\tilde{M}}\) is the system's Generalized Mass Matrix (\(\mathbf{\tilde{M}} = \mathbf{G}^\top \mathbf{M G}\)). (See Notation)

The principle says: out of all valid accelerations, nature chooses the one that minimizes this mass-weighted squared deviation from the free acceleration.

From Principle to Practice: The Simulator's Objective

To use this principle in a simulator, we must translate it into a concrete optimization problem that we can solve at each discrete time step \(h\).

1. Rephrasing in Terms of Constraint Forces

The difference between the true acceleration and the free acceleration is caused solely by constraint forces (\(f_c\)).

\[ \mathbf{a} - \mathbf{a_\text{free}} = (\mathbf{\tilde{M}}^{-1}(\mathbf{f_\text{ext}} + \mathbf{f_c})) - (\mathbf{\tilde{M}}^{-1}\mathbf{f_\text{ext}}) = \mathbf{\tilde{M}}^{-1}\mathbf{f_c} \]

If we substitute this back into the objective function (1), we find something remarkable:

\[ Z \propto \mathbf{f_c}^\top \mathbf{\tilde{M}}^{-1} \mathbf{f_c} \]

This reveals the powerful physical intuition of the principle: Minimizing the objective function \(Z\) is equivalent to finding the constraint forces of minimum magnitude. The system doesn't "work" any harder than it has to.

2. Formulating for the Next Velocity State

A solver doesn't work with abstract forces; it solves for the state at the next time step. Our primary unknown is the generalized velocity at the next step, \(\mathbf{u}^+\).

Using a simple backward Euler integration scheme, we can approximate the acceleration as:

\[ \mathbf{a} \approx \frac{\mathbf{u}^+ - \mathbf{u}^-}{h} \]

By substituting this and similar terms into the objective function and re-arranging, we can rewrite the entire minimization problem in terms of \(\mathbf{u}^+\). This yields the final objective function that Axion solves:

\[ \min_{\mathbf{u}^+} \quad (\mathbf{u}^+ - \tilde{\mathbf{u}})^\top \mathbf{\tilde{M}} (\mathbf{u}^+ - \tilde{\mathbf{u}}) \quad(2) \]

Where:

  • \(\mathbf{u}^+\) is the generalized velocity we are solving for. (See Notation)
  • \(\tilde{\mathbf{u}}\) is the predicted unconstrained velocity: \(\tilde{\mathbf{u}} = \mathbf{u}^- + h \mathbf{\tilde{M}}^{-1} \mathbf{f_\text{ext}}\). This is where the system "wants" to go.
  • \(\mathbf{\tilde{M}}\) is the Generalized Mass Matrix.

Solving with Lagrange Multipliers

The objective function (2) tells us what we want to minimize, but it must be solved subject to the system's constraints. These constraints dictate that the final velocity \(\mathbf{u}^+\) must be physically valid (e.g., no penetration, joints stay connected).

For a simplified case with only linear equality constraints (like a perfect hinge joint), we can write these constraints as:

\[ \mathbf{J} \mathbf{u}^{+} = \mathbf{0} \]

where \(\mathbf{J}\) is the constraint Jacobian. The optimization problem is now a classic Constrained Quadratic Program. A standard technique to solve this is the method of Lagrange multipliers. We introduce a vector of Lagrange multipliers, \(\boldsymbol{\lambda}\), one for each constraint equation. Physically, these multipliers represent the magnitude of the constraint impulses needed to enforce the constraints.

Solving this constrained problem yields a coupled system of linear equations for the unknowns \(\mathbf{u}^+\) and \(\boldsymbol{\lambda}\):

\[ \begin{align} \mathbf{\tilde{M}} \mathbf{u}^{+} + \mathbf{J}^\top \boldsymbol{\lambda} &= \mathbf{\tilde{M}} \mathbf{u}^- + h \mathbf{f_\text{ext}} \quad &(3)\\ \mathbf{J} \mathbf{u}^{+} &= \mathbf{0} \quad\quad\quad\quad\quad\;\;\; &(4) \end{align} \]

This system is fundamental. Equation (3) is the discretized equation of motion including the constraint impulses (\(\mathbf{J}^\top \boldsymbol{\lambda}\)), and equation (4) is the constraint condition itself. Together, they allow us to solve for the physically correct motion of the system.

Summary and Next Steps

Gauss's Principle of Least Constraint provides a powerful and robust foundation for our simulator. It transforms the complex problem of constrained dynamics into a standard mathematical optimization problem with a known solution: a Constrained Quadratic Program (CQP).

Our task is now clear:

Minimize the objective function (2) subject to the condition that the final velocity \(\mathbf{u}^+\) satisfies all physical constraint laws (e.g., non-penetration for contacts, velocity matching for joints).

The next step is to define these physical constraint laws mathematically. We will do this by formulating them as a set of nonlinear equations that must equal zero.

Next: The Complete Nonlinear System