Graphics Reference
In-Depth Information
1.2
1
0.8
0.6
0.4
0.2
0
0
0.5
1
1.5
2
2.5
x
Fig. 8.16.
Interpolating between the vectors [2 0]
T
and [0 1]
T
.
When interpolating vectors,
θ
is the angle between the two vectors. If this
is not known, it can be derived using the dot product formula:
V
1
·
V
2
cos(
θ
)=
(8.36)
V
1
V
2
cos(
θ
)=
x
1
x
2
+
y
1
y
2
+
z
1
z
2
V
1
V
2
When interpolating quaternions,
θ
is discovered by taking the 4D dot product
of the two quaternions:
q
1
·
q
2
cos(
θ
)=
q
2
cos(
θ
)=
s
1
s
2
+
x
1
x
2
+
y
1
y
2
+
z
1
z
2
q
1
q
1
q
2
If we are using unit quaternions,
cos(
θ
)=
s
1
s
2
+
x
1
x
2
+
y
1
y
2
+
z
1
z
2
(8.37)
We are now in a position to demonstrate how to interpolate between a pair of
quaternions. For example, say we have two quaternions
q
1
and
q
2
that rotate
0
◦
and 90
◦
about the
z
-axis respectively:
q
1
=
cos
0
◦
2
,
sin
0
◦
2
[0
,
0
,
1]
q
2
=
cos
90
◦
2
,
sin
90
◦
2
[0
,
0
,
1]
which become
q
1
=[1
,
[0
,
0
,
0]
q
2
=[0
.
7071
,
[0
,
0
,
0
.
7071]]