Game Development Reference

In-Depth Information

Hence, after computing Equation (10.20), we obtain

⎡

⎤

T
2
,
2
,T
2
,
3
,T
2
,
4

T
3
,
2
,T
3
,
3
,T
3
,
4

T
4
,
2
,T
4
,
3
,T
4
,
4

⎣

⎦
,

F
=

(10.21)

where
T
i,j
are the matrix
T
elements and
i, j

.

This technique requires storing
P
−
e
(see Equation (10.19)), i.e., 16 floating-

point numbers. Storing this matrix is useful when we have a detailed surface mesh

driven by the tetrahedral mesh, as we will show in Section 10.5.

Alternatively, we can compute the gradient
F
using the following, less-

memory-consuming technique, which requires only nine floats per element.

Let the matrix
D
e
of an element
e
be

∈{

1
,
2
,
3
,
4

}

⎡

⎤

p
1
,x
−

p
4
,x

p
2
,x
−

p
4
,x

p
3
,x
−

p
4
,x

⎣

⎦
,

D
e
=

p
1
,y
−

p
4
,y

p
2
,y
−

p
4
,y

p
3
,y
−

p
4
,y

p
1
,z
−

p
4
,z

p
2
,z
−

p
4
,z

p
3
,z
−

p
4
,z

where its elements are made by the element
e
nodes in their rest positions. Simi-

larly, we can build
G
e
using the nodes of the tetrahedron
e
in its deformed posi-

tion. Hence, the deformation gradient of the tetrahedron
e
can be defined as

F
=
G
e
D
−
e
.

Note that
G
e
changes in every iteration but
D
−
e
remains constant, so it can be

precomputed and stored using nine floating-point numbers.

Once we have computed
F
, we can extract the rotation using a polar decompo-

sition technique. The polar decomposition technique factorizes
F
in two matrices:

a rotation
R
and a positive definite symmetric matrix
U
. The polar decomposi-

tion computes the nearest unitary basis to the column axes. This ensures that the

U
contains the smallest deformation. The method initially computes
U
2
as
FF
T
.

Then we compute
U
as

U
=
√
U
2
=
λ
1
v
1
·

+
λ
2
v
2
·

+
λ
3
v
3
·

v
1

v
2

v
3
,

are the eigenvectors of
U
2
and

where

{

v
1
,v
2
,v
3
}

{

λ
1
,λ
2
,λ
3
}

are its associated

eigenvalues. Both

can be calculated using the Jacobi

transformations of a symmetric matrix. Describing this method is outside the

scope of this chapter, but the reader can refer to [Press et al. 07] for sample code

and further information. Finally, we can compute the tetrahedron rotation
R
from

R
=
FU
−
1
.

{

v
1
,v
2
,v
3
}

and

{

λ
1
,λ
2
,λ
3
}