60 likes | 198 Views
Lecture 07: Splines. February 12, 2013 COMP 150-2 Visualization. Cubic Splines. General form of a cubic spline: q(t) = a + bt * ct^2 + dt^3 q’(t) = b + 2ct + 3dt^2 Given: q(0) = S (starting point) q’(0) = Vs (velocity at point S) q(1) = G (goal point)
E N D
Lecture 07:Splines February 12, 2013 COMP 150-2Visualization
Cubic Splines • General form of a cubic spline: • q(t) = a + bt * ct^2 + dt^3 • q’(t) = b + 2ct + 3dt^2 • Given: • q(0) = S (starting point) • q’(0) = Vs (velocity at point S) • q(1) = G (goal point) • q’(1) = Vg (velocity at end point G)
Cubic Spline • Plug in the numbers: • q(0) = a + b(0) + c(0) + d(0) = S • => a = S • q’(0) = b + 2c(0) + 3d(0) = Vs • => b = Vs • Two remaining variables (c, d), two equations. Solve for c and d: • q(1) = a + b(1) + c(1) + d(1) = G • q’(1) = b + 2c + 3d = Vg
Cubic Spline • Plug in a = S, and b = Vs • q(1) = S + Vs + c + d = G ---- (eq1) • q’(1) = Vs + 2c + 3d = Vg ---- (eq2) • Solve for c first, (eq1)*3 – (eq2) • => c = -3S + 3G – 2Vs – 2Vg • Solve for d, (eq2) – ((eq1) * 2) • => d = 2S – 2G + Vs + Vg
Cubic Spline • Putting it all together: • q(t) = ( 1S + 0G + 0Vs + 0Vg) + • ( 0S + 0G + 1Vs + 0Vg) * t + • (-3S + 3G - 2Vs - 1Vg) * t * t + • ( 2S - 2G + 1Vs + 1Vg) * t * t * t • Test this by plugging in t = 0 and t = 1