Graphics Reference
In-Depth Information
11.9 Converting a Rotation Matrix to a Quaternion
The matrix transform equivalent to qpq 1
is
2 (s 2
x 2 )
+
1
2 (xy
sz)
2 (xz
+
sy)
x u
y u
z u
qpq 1
2 (s 2
y 2 )
=
2 (xy
+
sz)
+
1
2 (yz
sx)
2 (s 2
+ z 2 )
2 (xz sy)
2 (yz + sx)
1
a 11
a 12
a 13
x u
y u
z u
.
=
a 21
a 22
a 23
a 31
a 32
a 33
Inspection of the matrix shows that by combining various elements we can isolate
the terms of a quaternion s,x,y,z . For example, by adding the terms a 11 +
a 22 +
a 33
we obtain:
a 33 = 2 s 2
x 2
1 + 2 s 2
y 2
1 + 2 s 2
z 2
1
a 11 +
a 22 +
+
+
+
2 x 2
z 2
6 s 2
y 2
=
+
+
+
3
4 s 2
=
1
therefore,
2 1
1
s
+
a 11 +
a 22 +
a 33 .
To isolate x , y and z we use
1
4 s (a 32
x
=
a 23 )
1
4 s (a 13
y
=
a 31 )
1
4 s (a 21
z
=
a 12 ).
We can confirm their accuracy using the matrix ( 11.9 ):
1
2
3
1
2
2
3 +
2
3 +
1
3 =
s
+
3
4 2
2
3 +
2
3
1
6
x
=
=
3
4 2
2
3 +
2
3
1
6
y
=
=
3
4 2
1
3
1
3
z
=
=
0
which agree with the original values.
Say, for example, the value of s had been close to zero, this could have made the
values of x , y , z unreliable. Consequently, other combinations are available:
Search WWH ::




Custom Search