210 likes | 451 Views
Animating with Quaternions. Given quaternion representations, interpolate through them. Cubic, interpolating. Use operations efficient with quaternion representation. Halfway between 2 quaternions. Spherical Linear interpolation. Review of Quaternion Math. (cos( q /2),sin( q /2)*A).
E N D
Animating with Quaternions Given quaternion representations, interpolate through them Cubic, interpolating Use operations efficient with quaternion representation Halfway between 2 quaternions Spherical Linear interpolation
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
1-2y2-2z2 2xy-2wz 2xz+2wy 2yz-2wx 2xy+2wz 1-2x2-2z2 2yz+2wx 1-2x2-2y2 2xz-2wy Rotation Matrix of a Unit Quaternion [ w,x,y,z]
Review of Quaternion Rotations Rotq(v) = v’ = q * [0,v] * q-1 Rotq(v) = Rotk*q(v) Rotqp(v) = Rotq(Rotp(v) )
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
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) Linearly interpolate between quaternions q=(sq,xq,yq,zq), p=(sp,xp,yp,zp)
Euler Angles: [x,y,z] = (1- a)[xa,ya,za] + a[xb,yb,zb] Linear interpolation of quaternion values would give unequal rotation increments - need to slerp (spherical linear interpolation) Interpolation Scalar: K = (1-a) A + a B (linear interpolation: lerp) Quaternions?:
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
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.
Scalar: K = (1-a) A + a B (lerp) Euler Angles: [x,y,z] = (1-a)[xa,ya,za] + a[xb,yb,zb] Quaternions: q = (qbqa-1) a qa (slerp) Interpolation of rotations q = slerp(qa,qb, a)
p0 p1 p2 p3 -1 3 -3 1 p0 p1 p2 p3 3 -6 3 0 P(u) = [u3 u2 u 1] -3 3 3 0 1 0 0 0 Review of Bezier Interpolation Using Catmull-Romm interp of interior control points
Interpolation Background De Casteljau construction of Bezier curve u=1/3 P(1/3)
u=1/2 P(1/2) Interpolation Background Easy to compute quaternion half-way point q1/2 = q0 + q01
pn an pn+2 pn-1 an+1 bn+1 pn+1 1 Quaternion - cubic interpolation
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
Quaternion Interpolation Q n Double(q1,q2) = q2q1-1q2 P n Q n =Double(P n-1, P n) P n-1
Q n P n A n P n+1 P n-1 Construct Midpoint q1 + q2 = [s1,x1,y1,z1] + [s2,x2,y2,z2] Bisect(p,q) = (p+q)/||p+q|| A n =Bisect(Q n, P n+1)
Repeated mid-point interpolation For u = 1/4
Quaternion Interpolation Linearly interpolating between 4 keys Cubic Bezier interpolation among same 4 keys