Interpolation/Examples
Jump to navigation
Jump to search
Moves linearly upwards, then slides down speeding up and slowing down as well, then it takes a curvy path using a cubic curve to the beginning. Each step activated with a touch to show it in practice.
<lsl> 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{
touch_start( integer d ){ vector A = llGetPos(); vector B = A + < 0, 0, 2>; float x; while( x <= 1.0 ){ llSetPos( vLin( A, B, x += 0.05 ) ); } state Two; }
}
state Two{
touch_start( integer d ){ vector A = llGetPos(); vector B = A + < 2, 0,-2>; float x; while( x <= 1.0 ){ llSetPos( vCos( A, B, x += 0.05 ) ); } state Three; }
}
state Three{
touch_start( integer d ){ vector A = llGetPos(); vector B = A + <-2, 0, 0>; vector C = A + < 0, 4, 0>; vector D = A + <-2,-4, 0>; float x; while( x <= 1.0 ){ llSetPos( vCub( C, A, B, D, x += 0.05 ) ); } state default; }
} </lsl>