animating with quaternions
DESCRIPTION
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). - PowerPoint PPT PresentationTRANSCRIPT
Rick Parent - CIS681
Animating with Quaternions
Given quaternion representations, interpolate through them
Use operations efficient with quaternion representation
Halfway between 2 quaternions
Spherical Linear interpolation
Cubic, interpolating
Rick Parent - CIS681
Review of Quaternion Math
(cos(/2),sin(/2)*A)
[s1,v1] * [s2,v2] = [s1*s2-v1.v2,s1*v2+s2*v1+v1Xv2]
q-1 = [-s,v]/||q||2
||q|| = sqrt(s*s + x*x + y*y + z*z)
[s1,v1] + [s2,v2] = [s1+s2,v1+v2]
Rick Parent - CIS681
Rotation Matrix of a Unit Quaternion
1-2y2-2z2 2xy-2wz 2xz+2wy
1-2x2-2y22xz-2wy 2yz+2wx
1-2x2-2z22xy+2wz 2yz-2wx
[ w,x,y,z]
Rick Parent - CIS681
Review of Quaternion Rotations
Rotq(v) = v’ = q * [0,v] * q-1 Rotq(v) = Rotk*q(v)
Rotqp(v) = Rotq(Rotp(v) )
Rick Parent - CIS681
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
Rick Parent - CIS681
Linearly interpolate between quaternions
q=(sq,xq,yq,zq), p=(sp,xp,yp,zp)
q p
r() (1 )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)
Rotr(
1
2)(v) Rotqp (v)
Rick Parent - CIS681
Interpolation
Euler Angles: [x,y,z] = (1- )[xa,ya,za] + [xb,yb,zb]
K = (1-) A + BScalar: (linear interpolation: lerp)
Quaternions?: Linear interpolation of quaternion values would give unequal rotation increments - need to slerp (spherical linear interpolation)
Rick Parent - CIS681
Quaternion : Power Operator
[ cos(/2), sin( /2) * A] [cos(/2), sin( /2) * A] =
q rotates to q orientation as goes from 0 to 1
Remember: q and -q represent same orientation
q and (-q) give different rotation sequences0< < gives short squence; < <2 gives long one
Since first term in q is cos(/2), q gives short sequence if first term is positive
Rick Parent - CIS681
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.
Rick Parent - CIS681
Interpolation of rotations
Euler Angles: [x,y,z] = (1-a)[xa,ya,za] + a[xb,yb,zb]
K = (1-) A + BScalar: (lerp)
Quaternions: q = (qbqa-1) qa (slerp)
q = slerp(qa,qb, )
Rick Parent - CIS681
Review of Bezier Interpolation
P(u) = [u3 u2 u 1]
p0 p1 p2 p3
-1 1
1
3
3
33 3
-6
-3
-3 00
0 00
p0
p1
p2 p3
Using Catmull-Romm interp of interior control points
Rick Parent - CIS681
Bezier Interpolation of Quaternions
Rick Parent - CIS681
Interpolation Background
De Casteljau construction of Bezier curve
u=1/3
P(1/3)
Rick Parent - CIS681
Interpolation Background
Easy to compute quaternion half-way point
u=1/2
P(1/2)
q1/2 = q0 + q01
Rick Parent - CIS681
Quaternion - cubic interpolation
pn
pn-1
pn+1
pn+2
an+1
an
bn+1
1
Rick Parent - CIS681
Quaternion Interpolation
Automatically generating interior (spherical) control points
P n-1
P n
P n+1
Q n
A n
Double the arc
Bisect the span
Rick Parent - CIS681
Quaternion Interpolation
P n-1
P n
Q n Double(q1,q2) = q2q1-1q2
Q n =Double(P n-1, P n)
Rick Parent - CIS681
Construct Midpoint
P n-1
P n
P n+1
Q n
A n Bisect(p,q) = (p+q)/||p+q||
A n =Bisect(Q n, P n+1)
q1 + q2 = [s1,x1,y1,z1] + [s2,x2,y2,z2]
Rick Parent - CIS681
Spherical Linear Interpolation
p1 slerp(qn ,an, 13)
p2 slerp(an ,bn1, 13)
p3 slerp(bn1,qn1, 13)
p12 slerp(p1, p2, 13)
p23 slerp(p2, p3, 13)
p slerp(p12, p23, 13)
Rick Parent - CIS681
Repeated mid-point interpolation
For u = 1/4
temp slerp(qn ,an, 12) qn an
p1 slerp(qn ,temp, 12) qn temp
temp slerp(an ,bn1, 12) an bn1
p2 slerp(qn , temp, 12) qn temp
temp slerp(bn1,qn1, 12) bn1 qn1
p3 slerp(bn1,temp, 12) bn1 temp
temp slerp(p1, p2, 12) p1 p2
p12 slerp(p1, temp, 12) p1 temp
temp slerp(p2, p3, 12) p2 p3
p23 slerp(p2,temp, 12) p2 temp
temp slerp(p12, p23, 12) p12 p23
p23 slerp(p12,temp, 12) p12 temp
Rick Parent - CIS681
Quaternion Interpolation
Linearly interpolating between 4 keys
Cubic Bezier interpolation among same 4 keys
QuickTime™ and aVideo decompressor
are needed to see this picture.
QuickTime™ and aVideo decompressor
are needed to see this picture.