Difference between revisions of "Interpolation"

From Second Life Wiki
Jump to navigation Jump to search
m (User:Nexii Malthus/Interpolation moved to Interpolation: Changed my mind, should be working and is useable, wishing to add it to script library!)
(No difference)

Revision as of 18:45, 3 May 2008

<lsl> //===================================================// // Interpolation Library 1.0 // // "May 4 2008", "2:23:12" // // Copyright (C) 2008, Nexii Malthus (cc-by) // // http://creativecommons.org/licenses/by/3.0/ // //===================================================//

float fLin(float v0, float v1,float t){

   return v0*(1-t) + v1*t;}

float fCos(float v0,float v1,float t){

   float F = (1 - llCos(t*PI))/2;
   return v0*(1-F)+v1*F;}

float fCub(float v0,float v1,float v2,float v3,float t){

   float P = (v3-v2)-(v0-v1);float Q = (v0-v1)-P;float R = v2-v0;float S = v1;
   return P*llPow(t,3) + Q*llPow(t,2) + R*t + S;}

vector vLin(vector v0, vector v1,float t){

   return v0*(1-t) + v1*t;}

vector vCos(vector v0,vector v1,float t){

   float F = (1 - llCos(t*PI))/2;
   return v0*(1-F)+v1*F;}

vector vCub(vector v0,vector v1,vector v2,vector v3,float t){

   vector P = (v3-v2)-(v0-v1);vector Q = (v0-v1)-P;vector R = v2-v0;vector S = v1;
   return P*llPow(t,3) + Q*llPow(t,2) + R*t + S;}

default{state_entry(){}}

</lsl>