Presentation is loading. Please wait.

Presentation is loading. Please wait.

Animating with Quaternions

Similar presentations


Presentation on theme: "Animating with Quaternions"— Presentation transcript:

1 Animating with Quaternions
Given quaternion representations, interpolate through them Cubic, interpolating Use operations efficient with quaternion representation Halfway between 2 quaternions Spherical Linear interpolation

2 Review of Quaternion Math
(cos(q/2),sin(q/2)*A) [s1,v1] + [s2,v2] = [s1+s2,v1+v2] [s1,v1] * [s2,v2] = [s1*s2-v1.v2,s1*v2+s2*v1+v1Xv2] ||q|| = sqrt(s*s + x*x + y*y + z*z) q-1 = [-s,v]/||q||2

3 Rotation Matrix of a Unit Quaternion
[ w,x,y,z] 1-2y2-2z2 2xy-2wz 2xz+2wy 1-2x2-2y2 2xz-2wy 2yz+2wx 1-2x2-2z2 2xy+2wz 2yz-2wx

4 Review of Quaternion Rotations
Rotq(v) = v’ = q * [0,v] * q-1 Rotq(v) = Rotk*q(v) Rotqp(v) = Rotq(Rotp(v) )

5 spherical linear interpolation
Quaternions as points on a 4D sphere Unit quaternion: q=(s,x,y,z), ||q|| = 1 Want equal increment along arc connecting two quaternions on surface of sphere spherical linear interpolation

6 Linearly interpolate between quaternions
q=(sq,xq,yq,zq), p=(sp,xp,yp,zp) q p Note: Simply adding quaternions gives mid-rotation (because a scalar multiple of a quaternion represents the same rotation, you don’t need to divide by 2 to get the ‘average’ rotation)

7 Interpolation Scalar: K = (1-a) A + a B Euler Angles:
(linear interpolation: lerp) Euler Angles: [x,y,z] = (1- a)[xa,ya,za] + a[xb,yb,zb] Quaternions?: Linear interpolation of quaternion values would give unequal rotation increments - need to slerp (spherical linear interpolation)

8 Quaternion : Power Operator
[ cos(q/2), sin(q /2) * A] a = [cos(aq/2), sin(aq /2) * A] q a rotates to q orientation as a goes from 0 to 1 Remember: q and -q represent same orientation q a and (-q) a give different rotation sequences 0< q < p gives short squence; p < q <2 p gives long one Since first term in q is cos(q/2), q gives short sequence if first term is positive

9 Quaternions as points on a 4D sphere
Remember: Rot[s,v] == Rot[-s,-v] Use quaternion representations that are ‘close’ to each other: Given quaternion p, should you interpolate to q or -q? p and q are close if their 4D dot product is greater than zero.

10 Interpolation of rotations
K = (1-a) A + a B Scalar: (lerp) Euler Angles: [x,y,z] = (1-a)[xa,ya,za] + a[xb,yb,zb] Quaternions: q = (qbqa-1) a qa (slerp) q = slerp(qa,qb, a)

11 Review of Bezier Interpolation
Using Catmull-Romm interp of interior control points p0 p1 p2 p3 P(u) = [u3 u2 u 1] p0 p1 p2 p3 -1 1 3 -6 -3

12 Bezier Interpolation of Quaternions

13 Interpolation Background
De Casteljau construction of Bezier curve u=1/3 P(1/3)

14 Interpolation Background
Easy to compute quaternion half-way point q1/2 = q0 + q01

15 Quaternion - cubic interpolation
pn pn-1 pn+1 pn+2 an 1 an+1 bn+1

16 Quaternion Interpolation
Automatically generating interior (spherical) control points Q n P n A n P n+1 Bisect the span P n-1 Double the arc

17 Quaternion Interpolation
Q n Double(q1,q2) = q2q1-1q2 P n Q n =Double(P n-1, P n) P n-1

18 Construct Midpoint q1 + q2 = [s1,x1,y1,z1] + [s2,x2,y2,z2] Q n P n A n
Bisect(p,q) = (p+q)/||p+q|| A n =Bisect(Q n, P n+1)

19 Spherical Linear Interpolation

20 Repeated mid-point interpolation
For u = 1/4

21 Quaternion Interpolation
Linearly interpolating between 4 keys Cubic Bezier interpolation among same 4 keys


Download ppt "Animating with Quaternions"

Similar presentations


Ads by Google