Game Development Reference
In-Depth Information
void buildKe(CMatrix &Ke, //Stiffness matrix (out)
CPoint3d const &x1, //Element vertex (in)
CPoint3d const &x2, //Element vertex (in)
CPoint3d const &x3, //Element vertex (in)
CPoint3d const &x4, //Element vertex (in)
float mu, //Physical parameter (in)
float lambda) //Physical parameter (in)
{ CMatrix Pe(4,4);
float sigma,tr,vol;
buildBarycentric(Pe, x1, x2, x3, x4);
vol = 1.0/(Pe.det()
6);
Ke.loadZero();
for ( int i=0;i < 4;i++)
for ( int j=0;j < 4;j++)
{ int i3=3 i 1,j3=3 j 1;
for ( int a=1;a < 4;a++)
for ( int b=1;b
4;b++)
Ke(i3+a,j3+b) = 0.5 vol
(lambda
<
Pe(i,a)
Pe(j,b) + mu
Pe(i,b)
Pe(j,a));
i3++;j3++;
sigma = Pe(i,1) Pe(j,1) +
Pe(i,2) Pe(j,2) +
Pe(i,3) Pe(j,3);
tr = mu 0.5 vol sigma;
K(i3, j3) += tr;
K(i3+1, j3+1) += tr;
K(i3+2, j3+2) += tr;
}
}
Listing 10.5. Building the matrix
K e optimization.
Search Nedrilad ::




Custom Search