Skip to content

Commit 96b956e

Browse files
committed
- bugfix
1 parent e98aab4 commit 96b956e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

examples/pbd.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ <h3>4. Position correction:</h3>
141141
The position correction for a particle is determined using the Lagrange multiplier:
142142
$$\begin{align*}
143143
\Delta \mathbf x_{i_1} &= \frac{1}{m_{i_1}} \frac{\partial C_i}{\partial \mathbf x_{i_1}} \lambda_i = -\frac{\frac{1}{m_{i_1}}}{\frac{1}{m_{i_1}} + \frac{1}{m_{i_2}}}(\|\mathbf{x}_{i_1} - \mathbf{x}_{i_2}\|-d)\frac{\mathbf{x}_{i_1}- \mathbf{x}_{i_2}}{\|\mathbf{x}_{i_1} - \mathbf{x}_{i_2}\|} \\
144-
\Delta \mathbf x_{i_2} &= \frac{1}{m_{i_2}} \frac{\partial C_i}{\partial \mathbf x_{i_2}} \lambda_i = +\frac{\frac{1}{m_{i_2}}}{\frac{1}{m_{i_1}} + \frac{1}{m_{i_2}}}(\|\mathbf{x}_{i_1} - \mathbf{x}_{i_2}\|-d)\frac{\mathbf{x}_{i_1}- \mathbf{x}_{i_2}}{\|\mathbf{x}_{i_1} - \mathbf{x}_{i_2}\|}
144+
\Delta \mathbf x_{i_2} &= \frac{1}{m_{i_2}} \frac{\partial C_i}{\partial \mathbf x_{i_2}} \lambda_i = +\frac{\frac{1}{m_{i_1}}}{\frac{1}{m_{i_1}} + \frac{1}{m_{i_2}}}(\|\mathbf{x}_{i_1} - \mathbf{x}_{i_2}\|-d)\frac{\mathbf{x}_{i_1}- \mathbf{x}_{i_2}}{\|\mathbf{x}_{i_1} - \mathbf{x}_{i_2}\|}
145145
\end{align*}$$
146146
and the correction is applied to update $\mathbf x^*$ as
147147
$$\mathbf x^* := \mathbf x^* + \Delta \mathbf x.$$
@@ -302,7 +302,7 @@ <h3>References</h3>
302302
gradC_x = dx/dl;
303303
gradC_y = dy/dl;
304304
let K = (gradC_x*gradC_x + gradC_y*gradC_y) / this.mass;
305-
if (i != 0)
305+
if ((this.isActive(index1) && this.isActive(index2)))
306306
K = 2*K;
307307

308308
// comute Lagrange multiplier

examples/xpbd.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ <h3>References</h3>
325325
gradC_x = dx/dl;
326326
gradC_y = dy/dl;
327327
let K = (gradC_x*gradC_x + gradC_y*gradC_y) / this.mass;
328-
if (i != 0)
328+
if ((this.isActive(index1) && this.isActive(index2)))
329329
K = 2*K;
330330
K += alpha_tilde;
331331

0 commit comments

Comments
 (0)