• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
ゲームグラフィックス特論 第4回 講義ノート
 

ゲームグラフィックス特論 第4回 講義ノート

on

  • 451 views

四元数ほか。まだ書きかけです。

四元数ほか。まだ書きかけです。

Statistics

Views

Total Views
451
Views on SlideShare
451
Embed Views
0

Actions

Likes
4
Downloads
26
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    ゲームグラフィックス特論 第4回 講義ノート ゲームグラフィックス特論 第4回 講義ノート Document Transcript

    • 119 8 8.1 ( ) quaternion ( ) a, b i a + bi w, x, y, z i, j, k w + xi + yj + zk ! qx, qy, qz, qw (24) (qx, qy, qz) qv (25) ! (26) 8.2 ! (27) qv (28) ! qv qw (29) ˆq = (qx, qy, qz, qw) qv = (qx, qy, qz) ˆq = (qv, qw) ˆq = (qv, qw) = iqx + jqy + kqz + qw qv = (qx, qy, qz) = (iqx + jqy + kqz) ˆq = qv + qw
    • 120 i, j, k (30) 8.3 8.3.1 (31) C qmul() p, q, r x, y, z, w 4 q r p /** ***p*<K*q***r* */* void*qmul(float**p,*const*float**q,*const*float**r)* {* **p[0]*=*q[1]*r[2]*K*q[2]*r[1]*+*r[3]*q[0]*+*q[3]*r[0];* **p[1]*=*q[2]*r[0]*K*q[0]*r[2]*+*r[3]*q[1]*+*q[3]*r[1];* **p[2]*=*q[0]*r[1]*K*q[1]*r[0]*+*r[3]*q[2]*+*q[3]*r[2];* **p[3]*=*q[3]*r[3]*K*q[0]*r[0]*K*r[1]*q[1]*K*q[2]*r[2];* }* 8.3.2 (32) 8.3.3 (33) 8.3.4 (34) i2 = j2 = k2 = ijk = 1 jk = kj = i, ki = ik = j, ij = ji = k ˆqˆr = (iqx + jqy + kqz + qw)(irx + jry + krz + rw) = i(qyrz qzry + rwqx + qwrx) + j(qzrx qxrz + rwqy + qwry) + j(qxry qyrx + rwqz + qwrz) + qwrw qxrx qyry qzrz = (qv ⇥ rv + rwqv + qwrv, qwrw qv · rv) ˆq + ˆr = (qv, qw) + (rv, rw) = (qv + rv, qw + rw) ˆq⇤ = (qv, qw)⇤ = ( qv, qw) n(ˆq) = p ˆqˆq⇤ = p ˆq⇤ˆq = q q2 x + q2 y + q2 z + q2 w
    • 121 8.3.5 (35) (31) ! = ! (36) 8.3.6 (37) (38) 8.4 8.4.1 (39) (40) (41) 8.4.2 (42) (43) ˆi = (0, 1) ˆqˆi = (qv ⇥ rv + rwqv + qwrv, qwrw qv · rv) = (qv ⇥ 0 + 1qv + qw0, qw1 qv · 0) = (qv, qw) = ˆq n(ˆq) = p ˆqˆq⇤ , p ˆqˆq⇤ n(ˆq) = 1 ˆq 1 = ˆq⇤ |n(ˆq)|2 (ˆq⇤ )⇤ = ˆq (ˆq + ˆr)⇤ = ˆq⇤ + ˆr⇤ (ˆqˆr)⇤ = ˆr⇤ ˆq⇤ n(ˆq⇤ ) = n(ˆq) n(ˆqˆr) = n(ˆq)n(ˆr)
    • 122 8.4.3 (44) (45) 8.5 8.5.1 ( ) 1 (46) ! !! !! = 1 (47) ! 1 (48) cos ! + ! sin ! = !!" ! (49) 8.5.2 (49) !! (50) 8.5.3 (49) (51) 8.5.4 (38) ! ! = 1 (52) ˆp(sˆq + tˆr) = sˆpˆq + tˆpˆr ˆp(ˆqˆr) = (ˆpˆq)ˆr n(ˆq) = 1 ˆq = (sin uq, cos ) = sin uq + cos n(ˆq) = n(sin uq, cos ) = q sin2 (uq · uq) + cos2 = q sin2 + cos2 = 1 ˆq = sin uq + cos = e uq log ˆq = log(e uq ) = uq ˆqt = (sin uq + cos )t = e tuq = sin t uq + cos t ˆq 1 = ˆq⇤ |n(ˆq)|2 = ˆq⇤
    • 123 8.5.5 p (53) ! pv = (px, py, pz) (54) ! (55) !′ 100 ! !! 2! (56) !!! = !∗ (57) 100 ! −! (58) " X (59) p = 0 B B @ px py pz pw 1 C C A ˆp = (pv, pw) pv = (px, py, pz) ˆq = (sin uq, cos ) = sin uq + cos ˆp0 = ˆqˆpˆq 1 ˆp0 = ˆqˆpˆq⇤ uq φ" φ" ˆp ˆp´ ˆp0 = ( ˆq)ˆp( ˆq⇤ ) = ˆqˆpˆq⇤ ˆqx(✓) = ✓ sin ✓ 2 , 0, 0, cos ✓ 2 ◆ = i sin ✓ 2 + cos ✓ 2
    • 124 " Y (60) " Z (61) " C qmake() x, y, z a q /** ***q*<K* (x,*y,*z)* (a)* */* void*qmake(float**q,*float*x,*float*y,*float*z,*float*a)* {* **float*l*=*x***x*+*y***y*+*z***z;* * **if*(l*!=*0.0f)*{* ****float*s*=*sin(a**=*0.5f)*/*sqrt(l);* * ****q[0]*=*x***s;* ****q[1]*=*y***s;* ****q[2]*=*z***s;* ****q[3]*=*cos(a);* **}* }* 8.5.6 ! ! (62) ! ! !! ˆqy(✓) = ✓ 0, sin ✓ 2 , 0, cos ✓ 2 ◆ = j sin ✓ 2 + cos ✓ 2 ˆqz(✓) = ✓ 0, 0, sin ✓ 2 , cos ✓ 2 ◆ = k sin ✓ 2 + cos ✓ 2 ˆr(ˆqˆpˆq⇤ )ˆr⇤ = (ˆrˆq)ˆp(ˆq⇤ ˆr⇤ ) = (ˆrˆq)ˆp(ˆrˆq)⇤
    • 125 8.5.7 ! = (!!, !!, !!, !!) (63) ! = 2/!(!) ! (64) " C qrot() q m /** *** *m*<K* *q* */* void*qrot(float**m,*const*float**q)* {* **float*xx*=*q[0]***q[0]***2.0f;* **float*yy*=*q[1]***q[1]***2.0f;* **float*zz*=*q[2]***q[2]***2.0f;* **float*xy*=*q[0]***q[1]***2.0f;* **float*yz*=*q[1]***q[2]***2.0f;* **float*zx*=*q[2]***q[0]***2.0f;* **float*xw*=*q[0]***q[3]***2.0f;* **float*yw*=*q[1]***q[3]***2.0f;* **float*zw*=*q[2]***q[3]***2.0f;* * **m[*0]*=*1.0f*K*yy*K*zz;* **m[*1]*=*xy*+*zw;* **m[*2]*=*zx*K*yw;* **m[*4]*=*xy*K*zw;* **m[*5]*=*1.0f*K*zz*K*xx;* **m[*6]*=*yz*+*xw;* **m[*8]*=*zx*+*yw;* **m[*9]*=*yz*K*xw;* **m[10]*=*1.0f*K*xx*K*yy;* **m[*3]*=*m[*7]*=*m[11]*=* **m[12]*=*m[13]*=*m[14]*=*0.0f;* **m[15]*=*1.0f;* }* Mq = 0 B B @ 1 s(q2 y + q2 z) s(qxqy qwqz) s(qzqx + qwqy) 0 s(qxqy + qwqz) 1 s(q2 z + q2 x) s(qyqz qwqx) 0 s(qzqx qwqy) s(qyqz + qwqx) 1 s(q2 x + q2 y) 0 0 0 0 1 1 C C A Mq = 0 B B @ 1 2(q2 y + q2 z) 2(qxqy qwqz) 2(qzqx + qwqy) 0 2(qxqy + qwqz) 1 2(q2 z + q2 x) 2(qyqz qwqx) 0 2(qzqx qwqy) 2(qyqz + qwqx) 1 2(q2 x + q2 y) 0 0 0 0 1 1 C C A
    • 126 8.5.8 Mq (65) ( ) (66) qw (67) qx, qy, qz (68) (69) (70) qx, qy, qz (71) 8.6 s t s t u 2φ Mq = 0 B B @ mq 00 mq 01 mq 02 mq 03 mq 10 mq 11 mq 12 mq 13 mq 20 mq 21 mq 22 mq 23 mq 30 mq 31 mq 32 mq 33 1 C C A = 0 B B @ 1 2(q2 y + q2 z) 2(qxqy qwqz) 2(qzqx + qwqy) 0 2(qxqy + qwqz) 1 2(q2 z + q2 x) 2(qyqz qwqx) 0 2(qzqx qwqy) 2(qyqz + qwqx) 1 2(q2 x + q2 y) 0 0 0 0 1 1 C C A tr(Mq ) = 3X i=0 mq ii = m00 + m11 + m22 + m33 = 4 4(q2 x + q2 y + q2 z) = 4q2 w qw = 1 2 p tr(Mq) qx = mq 21 mq 12 4qw qy = mq 02 mq 20 4qw qz = mq 10 mq 01 4qw qx = 1 2 q +mq 00 mq 11 mq 22 + mq 33 qy = 1 2 q mq 00 + mq 11 mq 22 + mq 33 qz = 1 2 q mq 00 mq 11 + mq 22 + mq 33
    • 127 101 ! u (102) (103) !×! = sin 2! = 2 sin ! cos ! (102) (104) ! ∙ ! = cos 2! = 2 cos! ! − 1 = ! (105) (106) R(s, t) (107) s t 2φ u ˆq = (sin u, cos ) u = s ⇥ t ks ⇥ tk ˆq = ✓ sin sin 2 s ⇥ t, cos ◆ = ✓ 1 2 cos s ⇥ t, cos ◆ cos = r 1 + e 2 ˆq = 1 p 2(1 + e) s ⇥ t, p 2(1 + e) 2 ! R(s, t) = 0 B B @ e + hu2 x huxuy uz huzux + uy 0 huxuy + uz e + hu2 y huyuz ux 0 huzux uy huyuz + ux e + hu2 z 0 0 0 0 1 1 C C A u = (ux, uy, uz) = s ⇥ t ks ⇥ tk e = cos 2 = s · t h = 1 cos 2 sin2 2 = 1 e u · u