10.08.2013 Views

thesis - Computer Graphics Group - Charles University - Univerzita ...

thesis - Computer Graphics Group - Charles University - Univerzita ...

thesis - Computer Graphics Group - Charles University - Univerzita ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.2. CONSTRAINT ABSTRACTION 29<br />

and thus obtain<br />

¨Cp = (2 · (r1 − r2) · a1 − 2 · (r1 − r2) · a2) +<br />

J · v = 0<br />

(2 · (v1 − v2) · v1 − 2 · (v1 − v2) · v2)) =<br />

J · a + ˙<br />

J · v = 0<br />

J · a = c = − ˙<br />

J · v<br />

J = ( 2 · (r1 − r2) T | −2 · (r1 − r2) T ) = ( J1 J2 )<br />

J ˙ = ( 2 · (v1 − v2) T | −2 · (v1 − v2) T ) = ( ˙ J1<br />

˙<br />

J2 )<br />

c = − ˙<br />

J · v = −2 · (v1 − v2) · (v1 − v2),<br />

where J and ˙ J are 1×6 matrices (m×3n, m = 1, n = 2) defined in a block fashion. As we already<br />

<br />

<br />

∂Cp<br />

know J1 = ∂Cp<br />

∂r1 =<br />

∂r 1 1<br />

∂Cp<br />

∂r 2 1<br />

∂Cp<br />

∂r 3 1<br />

1×3<br />

= ∂ ˙<br />

Cp<br />

∂v1 =<br />

∂ ˙<br />

Cp<br />

∂v 1 1<br />

∂ ˙<br />

Cp<br />

∂v 2 1<br />

∂ ˙<br />

Cp<br />

∂v 3 1<br />

1×3 and J2 = ∂Cp<br />

∂r2<br />

= ∂ ˙<br />

Cp<br />

∂v2 .<br />

Now if F total<br />

1 and F total<br />

2 are the net forces acting on the first and second particles and M1 and<br />

M2 their mass matrices due to masses m1 and m2, we can form equation (4.6), A · λ + b = 0, and<br />

solve for λ (which is a scalar value likewise b, because m = 1).<br />

−1 <br />

T<br />

M1 0 J1 A = ( J1 J2 ) ·<br />

·<br />

0 M2 J T <br />

−1<br />

M1 0<br />

= ( J1 J2 ) ·<br />

2<br />

0 M −1<br />

<br />

T<br />

J1 ·<br />

2 J T <br />

2<br />

= ( J1 · M −1<br />

1 J2 · M −1<br />

<br />

T<br />

J1 2 ) ·<br />

J T <br />

= J1 · M<br />

2<br />

−1<br />

1 · J T 1 + J2 · M −1<br />

2 · J T 2<br />

−1 <br />

M1 0<br />

b = ( J1 J2 ) ·<br />

·<br />

− c = J1 · M<br />

0 M2<br />

−1<br />

1 · F total<br />

1 +<br />

J2 · M −1<br />

2<br />

Since J2 = −J1 = −2 · x T , Mi =<br />

A =<br />

b =<br />

=<br />

· F total<br />

2<br />

1<br />

m1<br />

1<br />

m1<br />

1<br />

m1<br />

− c<br />

m −1<br />

i 0 0<br />

0 m −1<br />

i<br />

F total<br />

1<br />

F total<br />

2<br />

0<br />

0 0 m −1<br />

i<br />

· J1 · J T 1 + 1<br />

m2<br />

· J1 · F total<br />

1 − 1<br />

<br />

and c = 2 · ˙ x · ˙ x we have<br />

· J1 · J T 1 = ( 1<br />

m2<br />

· 2 · x · F total<br />

1 − 1<br />

m2<br />

· J1 · F total<br />

2<br />

m1<br />

· 2 · x · F total<br />

2<br />

+ 1<br />

) · 4 · x · x<br />

m2<br />

− 2 · ˙ x · ˙ x<br />

λ = A −1 · (−b) = m1 · m2 · ˙ x · ˙ x + x · F total<br />

2<br />

− 2 · ˙ x · ˙ x<br />

2 · (m1 + m2) · x · x<br />

· m1 − x · F total<br />

1<br />

If Cp = ˙<br />

Cp = 0 then A = 0 because x > 0 (d > 0) and λ can be computed. Having known<br />

λ, constraint force Fc = ( F c 1 , F c 2 ) = J T · λ = (J T 1 · λ, J T 2 · λ) is evaluated, F c 1 applied to the first<br />

particle, F c 2 to the second particle and the simulator can advance further, obeying the constraint.<br />

4.2 Constraint Abstraction<br />

In the previous example we have shown how a particular constraint can be implemented by symbolically<br />

deriving the constraint function derivatives and building the equation (4.6) to compute<br />

the multipliers and the constraint force. What we actually did was that we hard-coded a certain<br />

particle model that would have to be updated (reprogrammed) whenever a new constraint had<br />

· m2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!