I have finished my cubic interpolation script. If anybody wants to use it for a terrain generator, then here you go:
//----------PROJECT: Resources for coding
//----------AUTHOR: SeanCanoodle
//----------PORTER: Axolotl (BL_ID 32440)
//----------SCRIPT: Cubic Interpolation
// Cubic interpolation algorithm made by SeanCanoodle of scratch.mit.edu
// http://scratch.mit.edu/projects/SeanCanoodle/1747215
//
// THIS SCRATCH TO TORQUESCRIPT PORT IS LICENSED UNDER:
// Creative Commons Attribution-ShareAlike 2.0 Generic (http://creativecommons.org/licenses/by-sa/2.0/deed.en)
// You may change this script and distribute it as long as you put this information on your project, and agree to the terms of this license.
function CubicInterpolate( %x1 , %x2 , %x3 , %x4 , %width ) //Returns a spaced list of numbers that are cubic interpolated.
{
for( %i = 0 ; %i <= %width ; %i++ )
{
%mu = ( 1 / %width ) * %i;
%mu2 = %mu * %mu;
%a0 = ( ( %x3 - %x2 ) - %x0 ) + %x1;
%a1 = ( %x0 - %x1 ) - %a0;
%a2 = %x2 - %x0;
%a3 = %x1;
%y3y2 = ( ( %a0 * %mu) * %mu2 ) + ( %a1 * %mu2 ); //calculate ax3 + bx2
%y1y0 = ( %a2 * %mu ) + %a3; //calculate cx + d
%result = %y3y2 + %y1y0; //now do (ax3 + bx2) + (cx + d)
%real = %real SPC %result; //concatenate every y value
}
return %real; //return concatenated y values
}