Game Development Reference
In-Depth Information
Taking the derivative ∂/∂A lm to the lm component of the matrix A yields
∂...
∂A lm
=2 A lm q m q m
2 p l q m .
Writing this again in matrix-vector notation, we get
2 ( Aq ) q T
pq T ,
and setting the derivative to zero brings us to
Aqq T
pq T
=0
= pq T
( qq T ) 1 .
A
·
Doing this calculation with the whole sum and the mass-weights would bring us
to
A =
i
1
m i p i q i
m i q i q i
.
i
This is great because this is a quantity we can actually calculate.
The second part we can throw away because it is symmetric and, thus, cannot
contain a rotation. The rest of the expression we call A pq . Just do the math:
A pq = zeroMatrix();
for each vertex v in v i.neighbors {
q=v.restPos
cm 0;
p = v.pos cm;
for all entries j, k
{
A pq[j][k] +=
v.mass
p[k]
q[j];
}
}
By so-called polar decomposition, we are now able to decompose the matrix
A pq into a rotation R and a scaling S :
A pq = RS .
How the scaling can be obtained can be understood intuitively: if we apply
A pq to a unit vector, the rotational part R will rotate the vector on the unit sphere,
but the scaling S will displace it from the shell of the unit sphere. Now we apply
A pq : the rotational part R T will rotate the vector back to the original position,
Search Nedrilad ::




Custom Search