You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/pbd.html
+32-20Lines changed: 32 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -93,71 +93,83 @@ <h3>Controls</h3>
93
93
<!-- Theory section -->
94
94
<divclass="card theory">
95
95
<h2>PBD algorithm:</h2>
96
-
This example shows the position based dynamics method introduced by Müller et al. [MHHR06,BMM17].
96
+
Instead of computing forces and integrating accelerations, as in classical force-based simulation, <b>position-based dynamics (PBD)</b> [MHHR06,BMM17] formulates physical relationships as geometric <b>constraints</b> and enforces them by directly displacing particle positions. This example simulates a piece of cloth: a regular grid of particles connected by distance constraints and hanging under gravity from one or more fixed corners. You can grab and drag any of the free particles with the mouse.
97
+
<p>Every time step the following steps are performed:</p>
97
98
<ol>
98
99
<li>time integration to predict particle positions</li>
where $d$ is the rest length between particles $\mathbf{x}_{i_1}$ and $\mathbf{x}_{i_2}$.
107
-
107
+
where $d$ is the rest length between particles $\mathbf{x}_{i_1}$ and $\mathbf{x}_{i_2}$; a constraint is satisfied once $C_i = 0$. Besides the horizontal and vertical structural constraints along the grid, diagonal constraints are added within each grid cell to resist shearing and keep the cloth from collapsing sideways.
108
+
108
109
<h3>1. Time integration</h3>
109
110
In the first step the particle positions are advected using a symplectic Euler method to obtain predicted positions $\mathbf x^*$:
\mathbf x^* &= \mathbf x(t) + \Delta t \mathbf v^*,
113
114
\end{align*}$$
114
-
where $\mathbf a_\text{ext}$ are accelerations due to external forces.
115
-
115
+
where $\mathbf a_\text{ext}$ are accelerations due to external forces (here: gravity). Note that this prediction ignores the distance constraints entirely, so $\mathbf x^*$ will generally violate them — correcting this is exactly the job of the solver loop below.
116
+
116
117
<h3>2. Solver loop</h3>
117
-
Position corrections are computed and applied in a loop using a fixed number of iterations.
118
-
118
+
The position corrections of all constraints are computed and applied one after another in a single sweep, and this sweep is repeated for a fixed number of iterations (Gauss-Seidel-style relaxation). Because each correction immediately updates the positions seen by the next constraint in the sweep, more iterations propagate the corrections further through the cloth and bring the particles closer to satisfying <em>all</em> constraints simultaneously. Unlike a spring stiffness constant in a force-based model, here it is the <b>number of iterations</b> (relative to the time step) that determines how stretchy or stiff the cloth appears — try reducing it in the controls panel and observe the effect.
119
+
119
120
<h3>3. Compute Lagrange multipliers</h3>
120
-
121
+
121
122
<p>The general form to compute the Lagrange multipliers in position-based dynamics is
where $j$ denotes the indices of the particles which are influenced by the constraint.
128
+
where $j$ denotes the indices of the particles which are influenced by the constraint. Fixed particles are excluded from this sum (their inverse mass is treated as zero), which is why they do not move under the correction below.
128
129
</p>
129
-
130
-
<p>To compute the Lagrange multipliers, the constraint gradients are required which are computed as: </p>
130
+
131
+
<p>To compute the Lagrange multipliers, the constraint gradients are required which are computed as: </p>
Note that heavier particles (larger mass $m$) receive a proportionally smaller correction — this is what makes the constraint respect the mass ratio between the two particles instead of always splitting the correction evenly.
147
+
146
148
<h3>5. Velocity update:</h3>
147
149
The final positions and velocities are computed as:
Rather than integrating forces, the velocity is simply reconstructed from how far the position moved during the step. This automatically accounts for all constraint corrections as if they had been caused by impulses, and it introduces a mild, built-in numerical damping (energy is removed whenever a correction shortens a particle's displacement) that contributes to the method's robustness.
156
+
157
+
<h3>Properties</h3>
158
+
<ul>
159
+
<li><b>Stable:</b> since a solver iteration always projects positions towards the constraint manifold rather than integrating a (possibly stiff) restoring force, PBD cannot blow up numerically even for large time steps or arbitrarily "stiff" constraints — unlike an explicit force-based spring model, which requires a very small time step to remain stable for stiff springs.</li>
160
+
<li><b>No physical stiffness parameter:</b> constraints are treated as hard constraints; the perceived stiffness of the cloth is governed by the number of solver iterations relative to the time step, not by a spring constant. Many iterations converge towards an inextensible cloth, while few iterations yield a visibly softer, more elastic look.</li>
161
+
<li><b>Simple and fast:</b> each iteration only evaluates constraint functions and their gradients directly on the positions; no force assembly or (potentially large, implicit) linear system needs to be built and solved. This simplicity is a key reason why PBD (and its successor, XPBD) is widely used for cloth, hair, and soft bodies in real-time applications such as games.</li>
162
+
<li><b>Approximate and iteration-dependent:</b> with only a fixed, small number of Gauss-Seidel sweeps, constraints are in general not fully satisfied. Corrections propagate only one constraint "hop" per iteration, so particles far away from a fixed point need more iterations before they feel its influence — increase the grid size in the controls and watch how much longer the cloth needs to settle.</li>
163
+
</ul>
164
+
The panel on the right also reports the measured time per simulation step, which grows with the number of particles, constraints and iterations — try increasing the grid resolution or the iteration count to see this trade-off between accuracy and performance directly.
165
+
154
166
<h3>References</h3>
155
167
<ul>
156
168
<li>[MHHR06] Matthias Müller, Bruno Heidelberger, Marcus Hennix, John Ratcliff. Position Based Dynamics. In Proceedings of Virtual Realitiy, Interactions, and Physical Simulation, 2006. Eurographics Association.</li>
157
169
<li>[BMM17] Jan Bender, Matthias Müller, Miles Macklin. A Survey on Position Based Dynamics, 2017. Eurographics Tutorials, 2017</li>
0 commit comments