Game Development Reference
In-Depth Information
In general, instead of solving each element separately, we group all the exter-
nal forces into one global vector and the stiffness matrix into a larger-dimension
global matrix:
F ext =
e
f e
and
e K e, 1 , 1 e K e, 1 , 2
··· e K e, 1 ,n
.
. . .
e K e,n, 1 K e,n, 2
,
K =
K e,n,n
···
where e K e,i,j is the stiffness matrix of the tetrahedron e that relates node i
to node j . Note that the global matrix is sparse and symmetric semipositive-
semidefinite.
F ext .
K u =
We show how to build the barycentricmatrix of a tetrahedron and its displacement-
deformation matrix B e in Listings 10.1 and 10.2, respectively. These functions
void buildBarycentric (CMatrix &Pe, //Stiffness matrix (out)
CPoint3d const &x1, //Tetra vertex (in)
CPoint3d const &x2, //Tetra vertex (in)
CPoint3d const &x3, //Tetra vertex (in)
CPoint3d const &x4) //Tetra vertex (in)
{ for ( int i=0; i
<
4; i++)
Pe(0,i)= 1;
for ( int i=1; i < 4; i++)
Pe(i,0) = x1[i
1];
for ( int i=1; i < 4; i++)
Pe(i,1) = x2[i 1];
for ( int i=1; i < 4; i++)
Pe(i,2) = x3[i 1];
for ( int i=1; i < 4; i++)
Pe(i,3) = x4[i
1];
Pe = Pe.invert();
}
Listing 10.1. Building a barycentric matrix.