Graphics Reference
In-Depth Information
Rotating a point about a vector
qpq
−
1
=
(
1
−
cos
θ)(
ˆ
v
·
u
)
ˆ
v
+
cos
θ
u
+
sin
θ
ˆ
v
×
u
.
Rotating a frame about a vector
q
−
1
pq
=
−
ˆ
·
ˆ
+
−
ˆ
×
(
1
cos
θ)(
v
u
)
v
cos
θ
u
sin
θ
v
u
.
Matrix for rotating a point about a vector
⎡
⎤
⎡
⎤
2
(y
2
z
2
)
1
−
+
2
(xy
−
sz)
2
(xz
+
sy)
x
u
y
u
z
u
qpq
−
1
⎣
⎦
⎣
⎦
.
2
(x
2
z
2
)
=
2
(xy
+
sz)
1
−
+
2
(yz
−
sx)
2
(x
2
y
2
)
−
+
−
+
2
(xz
sy)
2
(yz
sx)
1
Matrix for rotating a frame about a vector
⎡
⎣
⎤
⎦
⎡
⎣
⎤
⎦
.
2
(y
2
+
z
2
)
1
−
2
(xy
+
sz)
2
(xz
−
sy)
x
u
y
u
z
u
q
−
1
pq
2
(x
2
z
2
)
=
2
(xy
−
sz)
1
−
+
2
(yz
+
sx)
2
(x
2
y
2
)
2
(xz
+
sy)
2
(yz
−
sx)
1
−
+
Matrix for a quaternion product
⎡
⎤
⎡
⎤
s
1
−
x
1
−
y
1
−
z
1
s
2
x
2
y
2
z
2
⎣
⎦
⎣
⎦
x
1
s
1
−
z
1
y
1
q
1
q
2
=
L(
q
1
)
q
2
=
y
1
z
1
s
1
−
x
1
z
1
−
y
1
x
1
s
1
⎡
⎣
⎤
⎦
⎡
⎣
⎤
⎦
s
2
−
x
2
−
y
2
−
z
2
s
1
x
1
y
1
z
1
x
2
s
2
z
2
−
y
2
q
1
q
2
=
R(
q
2
)
q
1
=
.
y
2
−
z
2
s
2
x
2
z
2
y
2
−
x
2
s
2
Interpolating two quaternions
sin
(
1
−
t)θ
sin
tθ
sin
θ
q
=
q
1
+
q
2
sin
θ
where
q
1
·
q
2
cos
θ
=
|
q
1
||
q
2
|
s
1
s
2
+
x
1
x
2
+
y
1
y
2
+
z
1
z
2
cos
θ
=
.
|
q
1
||
q
2
|
Quaternion from a rotation matrix
2
1
1
s
=±
+
a
11
+
a
22
+
a
33
1
4
s
(a
32
−
x
=
a
23
)
1
4
s
(a
13
−
y
=
a
31
)
1
4
s
(a
21
−
z
=
a
12
)