(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

I'm trying to write a Lagrange-multiplier constraint simulation along the lines of those described by Andrew Witkin here.

The basic idea for this simulation is that you have a number of objects represented by three collinear beads joined by massless rods; one of the two rods changes length, and the other has a fixed length (the beads are in liquid interacting via rotne-prager tensor interactions, but the physics is not the gist of this question). The simulation works by calculating the Jacobian matrix of the constraints, using it to calculate Lagrange multipliers, finding constraint forces, and proceeding.

So we have two constraints:

1) the two beads of the fixed-length leg must remain the same distance apart, and

2) the three beads must remain collinear.

Here's the rub: I have the thing working wonderfully in 2d, but cannot for the life of me get it to behave in 3d.

For terminology, we'll label the beads 1-3 and say that leg 1-2 is changing length and 2-3 is remaining fixed.

2. Relevant equations

In 2d, the first constraint is that [tex]r_23 = \delta[/tex], which we can rewrite as [tex]C=r_{23}^2 - \delta^2 = 0[/tex], or

[tex]C=((x_3-x_2)^2+(y_3-y_2)^2=0[/tex]

[tex]C = x_{3}^{2} - 2x_{2}x_{3} + x_{2}^{2} + y_{3}^2 - 2y_{2}y_{3} + y_2{^2} - \delta^2 = 0[/tex]

So the Jacobian [tex]J_i = \frac{\partial C}{\partial q_{i}}[/tex] is

[tex]J=[ 0, 0, 2x_{2}-2x_{3}, 2y_{2}-2y{3}, 2x_{3}-2x_{2}, 2y_{3}-2y{2} ][/tex]

and we can remove the spurious 2's to get

[tex]J=[ 0, 0, x_{2}-x_{3}, y_{2}-y_{3}, x_{3}-x_{2}, y_{3}-y_{2} ][/tex]

For the second constraint in 2d (collinear), I used equivalent slopes:

[tex]\frac{y_{\alpha}}{x_{\alpha}} = \frac{y_{\beta}}{x_{\beta}}[/tex]

[tex]C=y_{\alpha}x_{\beta}-y_{\beta}x_{\alpha} = 0[/tex]

[tex]C=(y_{3}-y_{2})(x_{2}-x_{1}) - (y_{2}-y_{1})(x_{3}-x_{2})[/tex]

[tex]C=y_{3}x_{2}-y_{3}x_{1}-y_{2}x_{2}+y_{2}x_{1}-y_{2}x_{3}+y_{2}x_{2}+y_{1}x_{3}+y_{1}x_{2}[/tex]

and so the Jacobian is

[tex]J=[y_{2}-y_{3}, x_{3}-x_{2}, y_{3}-y_{1}, x_{1}-x_{3}, y_{1}-y_{2}, x_{2}-x_{1}][/tex]

(hopefully I've transcribed all that correctly). Okay--so far in 2d, all this works beautifully.

...(continued)

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Lagrange-multiplier constraint for collinear beads in 3d?

**Physics Forums | Science Articles, Homework Help, Discussion**