Game Development Reference
In-Depth Information
Figure 14.5. A vertex that has been displaced relative to its neighborhood should feel a
back-driving force that maintains surface details.
ferent distances? The best translation of the rest positions is the one that matches
the centers of mass of the initial (rest) shape and the deformed shape ( Figure 14.6
( left ) ).
This results in the following goal positions:
c i = x i
( x cm
x cm ) .
For this quantity, we need to calculate the centers of mass for the original and the
deformed shapes:
for each vertex v in v i.neighbors
{
cm += v.pos; cm 0 += v.goalPos;
masses += v.mass;
cm /= masses; cm 0 /= masses;
This is still not the optimal solution because the rotational degree of freedom has
not yet been used. It is introduced in the form of the matrix R , which repre-
sents the optimal rotation of the point cloud around the matched centers of mass
The optimal rigid transformation
c i = R ( x i
x cm )+ x cm
has the property that it minimizes the quantity
x i ) 2 .
m i ( c i
i
This matches the goal positions and the actual coordinates in the “least-squares
sense.” Additionally, it takes care of the fact that heavy particles are harder to