Graphics Reference
In-Depth Information
Object A
Object hierarchy
T
=
[4 2 0]
Object A
Object B
Object C
R
=
I
S
=
[1 2 2]
Object B
T
=
[0.25 0.25 0]
Y
π
4
R
=
R
Z
S
=
[0.3 0.3 0.3]
Object C
A
T
=
[-1 0 0]
π
4
R
=
R
Z
S
=
[0.3 0.3 0.3]
X
Figure 3.2.
Modified example.
3.2.4 Decomposition of Global Transform to TRS
While we already know that in the standard TRS system, due to skew, we cannot
always decompose a global transformation into global TRS values, we aim to find
an algorithm that gives us at least an approximate solution.
Let an object have
n
ancestors in the hierarchy tree. Let
M
1
,
M
2
,
,
M
n
be their local transformation matrices,
M
0
be a local transformation matrix of
the considered object, and
M
i
=
S
i
R
i
T
i
.
Let us denote
M
TRS
Σ
=
M
0
M
1
···
···
M
n
(
TRS
Σ means here that the matrix
holds pretty much everything including translation, rotation, scale, and skew).
We also define
M
TR
=
R
0
T
0
R
1
T
1
···
R
n
T
n
(
TR
indicates that the matrix holds
information about translation and rotation).
Global translation is easily extractible from
M
TRS
Σ
; we just look at the fourth
row of the matrix.
Global rotation is determined simply by taking
M
TR
stripped of the transla-
tion vector, giving us
M
R
matrix. This matrix will usually have to be converted
to a quaternion or to Euler angles. [Dunn and Parberry 02] provides extensive
coverage on how to do this.
Global scale is the trickiest part. To get reasonable values for it, we determine
M
RS
Σ
matrix (which is
M
TRS
Σ
matrix with zeroed translation part). Then, we
compute
M
S
Σ
=
M
RS
Σ
M
R
−
1
. Voila—here we have the skew and the scale
combined. We use diagonal elements of
M
S
Σ
to get the scale, and we choose to
ignore the rest that is responsible for the skew.