Module: Moon::Interpolation::Helper

Included in:
Bezier, CatmullRom, Linear
Defined in:
lib/moon/packages/std/animation/interpolation.rb

Instance Method Details

#bernstein(n, i) ⇒ Object

 ``` 22 23 24``` ```# File 'lib/moon/packages/std/animation/interpolation.rb', line 22 def bernstein(n, i) factorial(n) / factorial(i) / factorial(n - i) end```

#catmull_rom(p0, p1, p2, p3, t) ⇒ Object

 ``` 26 27 28 29 30 31 32``` ```# File 'lib/moon/packages/std/animation/interpolation.rb', line 26 def catmull_rom(p0, p1, p2, p3, t) v0 = (p2 - p0) * 0.5 v1 = (p3 - p1) * 0.5 t2 = t * t t3 = t * t2 (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1 end```

#factorial(n) ⇒ Object

 ``` 5 6 7 8 9 10 11 12 13 14 15 16``` ```# File 'lib/moon/packages/std/animation/interpolation.rb', line 5 def factorial(n) a = [1] s = 1 if a[n] a[n] else n.times do |i| s *= (n - i) end a[n] = s end end```

#linear(p0, p1, t) ⇒ Object

 ``` 18 19 20``` ```# File 'lib/moon/packages/std/animation/interpolation.rb', line 18 def linear(p0, p1, t) (p1 - p0) * t + p0 end```