Upload
griffin-thompson
View
220
Download
0
Embed Size (px)
DESCRIPTION
3D Game Engine Design 3 Quaternion(cont’d)
Citation preview
3D Game Engine Design 1
3D Game Engine Design3D Game Engine DesignCh. 2.3.Ch. 2.3.
3D MAP LAB
3D Game Engine Design 2
QuaternionQuaternion
Quaternion Algebra Def >
A Quaternion is defined by q = w + xi + yj + zk where w, x, y, z are in R and
Def> Let
then
3D Game Engine Design 3
Quaternion(cont’d)Quaternion(cont’d)
2222* zyxwqq
3D Game Engine Design 4
Quaternion(cont’d)Quaternion(cont’d)
Thm>Let then and let then quaternion multiplication can be defined using vector dot product and cross product
Thm>A quaternion q may be also viewed as a 4D vector( w, x, y, z).then the dot product of two quaternion is
vwq ˆzkyjxiv ˆ ),,(ˆ zyxv
kxyyxzwzwjzxxzywywiyzzyxwxwzzyyxxww
xyyxzxxzyzzyzwywxwzwywxwzzyyxxww
vvvwvwvvwwvwvwqq
)()()()(
),,(),,(),,()(
ˆˆˆˆ)ˆˆ()ˆ)(ˆ(
1010011010100110
1010011010101010
101010101010
01010110101010101010
1001101010110010
)( *101010101010 qqWzzyyxxwwqq
3D Game Engine Design 5
Quaternion(cont’d)Quaternion(cont’d)
Def> A unit quaternion is a quaternion q for which
Thm> The inverse of unit quaternion and the product of unit quat
ernion are themselves unit quaternion.
Unit quaternion can be represented by
1)( qN
kw
zjw
yiw
xuandwwwhere
uq
kw
zjw
yiw
xwwq
zyxwzkyjxiwq
222
2
222
2
2222
111ˆ,1sin,cos
,sinˆcos
)111
(1
1,
3D Game Engine Design 6
Quaternion(cont’d)Quaternion(cont’d)
has length 1. However observe that the quaternion product similar to unit-length complex numbers
Euler’s identity for complex numbers generalizes to quaternion.
Thm> The power of unit quaternion
The logarithm of unit quaternion
),,(ˆ 210210 uuuvectorandkujuiuu
1ˆˆ uu sincos iz
sinˆcos:
sincos:'ˆ ueformGeneral
ieIdnetitysEuleru
i
)sin(ˆ)cos()sinˆ(cos tutuq tt
ueuq ueee ˆ)(log)sinˆ(coslog)(log ˆ
3D Game Engine Design 7
Quaternion(cont’d)Quaternion(cont’d)
Caution : standard identities are not allowed because of non-commutative of quaternion.
That is, )log(loglog qpqpandeee qpqp
3D Game Engine Design 8
Quaternion(cont’d)Quaternion(cont’d) Relationship to quaternion to rotation Thm>
Unit quaternion represents the rotation of the 3D vector by an angle about the 3D axis . And rotated vector is represented by . Proof>
it is enough to show that R(v) is 3D vector R(v) is length preserving function. R(v) is linear transformation. R(v) doesn’t have reflection component. Rotation axis is really u. ( 1) Rotation angle (2) We will prove (1),(2)
sinˆcos uq
v 2 u*ˆ)ˆ( qvqvR
2
3D Game Engine Design 9
Quaternion(cont’d)Quaternion(cont’d)
(1)
(2)
uu
uu
uuuuu
ququR
ˆ)sin(cosˆsinˆsincossincoscosˆ
)sinˆ)(cossincosˆ()sinˆ(cosˆ)sinˆ(cos
ˆ)ˆ(
22
22
*
)ˆ(ˆ)cos(ˆˆ
ˆˆˆ,ˆˆˆ,ˆˆˆ,0ˆˆˆˆˆˆ,.ˆˆ,ˆ
*
*
qvqvthenqvqtoangleanbyrotatedvvectorthethatassum
vuwanduwvwvuandwvwuvuisthatvectorslorthonormaofsethandedrightabewandvulet
u
v w
2
)ˆ( *qvq
3D Game Engine Design 10
Quaternion(cont’d)Quaternion(cont’d)
2)2cos(
])(sin)[(cos)]cossin2(ˆ)(sin)[(cos
)]cossin)ˆˆˆˆ()(sin)[(cos)cos(,
,ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ]cossin)ˆˆˆˆ()(sin)[(cos
])(sin)ˆˆ(cossinˆˆˆcossinˆˆ)(cosˆ[)]sinˆˆcosˆ)(sinˆˆcosˆ[(
)]sinˆ(cosˆ)sinˆ(cosˆ[)ˆˆ()ˆ(ˆ
22
22
22
22
22222
***
proofthecompletethis
WuW
vuvuWlyconsequent
uvwvwvwvuvandwuvuvuvuvnowvuvuW
uvvuvuvvWuvvuvvW
uvuvWqvqvWqvqv
3D Game Engine Design 11
Quaternion(cont’d)Quaternion(cont’d)
Conversion between various rotation representations
Angle-axis rotation
Quaternion rotation Rotation matrix
3D Game Engine Design 12
Quaternion(cont’d)Quaternion(cont’d)
Conversion between angle-axis and rotation matrix Thm> angle-axis to rotation matrix
00
0,)cos1()(sin
ˆ
01
02
12
2
2,1,0
uuuuuu
S
andmatrixidentitytheisIwhereSSIR
ismatrixrotationingcorrespondthenrotation
ofaxislengthunitthebeuuuuandrotationofangleanbeLet
3D Game Engine Design 13
Quaternion(cont’d)Quaternion(cont’d) Thm> Rotation matrix to angle-axis
00
0,)sin2(
2/)1)((cos:)(
??
01
02
12
221100
222120
121110
020100
uuuuuu
SwhereSRR
RtracethenrrrRtracedefine
axisanglethenrrrrrrrrr
R
T
=0 or 180(??)
3D Game Engine Design 14
Quaternion(cont’d)Quaternion(cont’d)
Conversion between quaternion and angle-axis Thm> angle-axis to quaternion
Thm> quaternion to angle-axis
).2/sin(),2/sin(),2/sin(),2/cos(,
),,(1),)(2/sin()2/cos(
210
210
2222210
uzanduyuxwarequaterniontheofcomponenttheaxisandangletheGiven
uuuuaxistheaboutbyrotationrepresentzyxwkujuiuzkyjxiwq
21
2222210
1/),,()(cos2
1),)(2/sin()2/cos(
wzyxuandw
zyxwkujuiuzkyjxiwq
3D Game Engine Design 15
Quaternion(cont’d)Quaternion(cont’d)
Conversion between quaternion and rotation matrix Thm> quaternion to rotation matrix
Thm> rotation matrix to quaternion
22
22
22
221222222221222222221
??
yxwxyzwyxzwxyzzxwzxywyxzwzxyzy
R
matrixRotationthenzkyjxiwq
)4/()(),4/()(),4/()(2/1)(
2/)1)((cos:)(
???
100102202112
221100
222120
121110
020100
wrrzwrrywrrxRtracewthen
RtracethenrrrRtracedefine
zkyjxiwqthenrrrrrrrrr
R