```
library Interpolation
function Linear_Intp takes real a, real b, real t returns real
return a + (b - a)*t
endfunction
function Bezier_Intp takes real a, real b, real c, real d, real t returns real
local real ab = a + (b - a)*t
local real bc = b + (c - b)*t
local real cd = c + (d - c)*t
local real m = ab + (bc - ab)*t
local real n = bc + (cd - bc)*t
return m + (n - m)*t
endfunction
function Bezier_Intp_Alt takes real a, real b, real c, real d, real t returns real
local real m = t*t
return a + 3*t*(b - a) + 3*m*(c - 2*b + a) + m*t*(3*(b-c) + d - a)
endfunction
function Power takes real n, integer pow returns real
if pow > 0 then
return n*Power(n,pow-1)
endif
return 1.0
endfunction
function GetCardTan takes real p1, real p3 returns real
return 0.5*(p3-p1)
endfunction
// t = tension, c = continuety, b = bias
// tension is how sharply the curve makes turns.
// continuety specifies the rate of change between speed and direction.
// bias specifies the direction of the curve.
// sidenote: specify p1 as 0, when working with 2 points
// the next function returns the intan of p2
function InTan takes real p1, real p2, real p3, real t, real c, real b returns real
return (1.0-t)*(1.0-c)*(1.0+b)*(p2-p1)/2 + (1.0-t)*(1.0+c)*(1.0-b)*(p3-p2)/2
endfunction
// the next function returns the outtan of p2
function OutTan takes real p1, real p2, real p3, real t, real c, real b returns real
return (1.0-t)*(1.0+c)*(1.0+b)*(p2-p1)/2 + (1.0-t)*(1.0-c)*(1.0-b)*(p3-p2)/2
endfunction
function Hermite_Intp takes real p1, real p2, real t1, real t2, real s returns real
local real s2 = s*s
local real h1 = 8.0*s*s2 - 9.0*s2
local real h2 = h1*(-1)
local real h3 = s2*(s - 2.0) + s
local real h4 = s2*(s - 1.0)
set h1 = h1 + 1
return h1*p1 + h2*p2 + h3*t1 + h4*t2
endfunction
endlibrary
```