Difference between revisions of "Interpolation/Cubic"
Jump to navigation
Jump to search
(Created page with "{{LSL Header|Interpolation}} {{RightToc|clear:right;}} == Cubic Interpolation == {|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1em…") |
m (→Rotation Cubic) |
||
Line 111: | Line 111: | ||
// Spherical-Cubic Interpolation | // Spherical-Cubic Interpolation | ||
// r0 = Start, r1 = End, r2 and r3 affect path of curve! | // r0 = Start, r1 = End, r2 and r3 affect path of curve! | ||
return rLin( rLin(r0,r1,t), rLin(r2,r3,t), 2*t*(1-t) );} | return rLin( rLin(r0,r1,t), rLin(r2,r3,t), 2*t*(1-t) ); | ||
} | |||
</lsl> | </lsl> | ||
Revision as of 13:57, 4 September 2011
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | Interpolation |
Cubic Interpolation
Float Cubic | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Cubic interpolation of f0, f1, f2 and f3 with fraction t. <lsl> float fCub(float f0,float f1,float f2,float f3,float t) { float P = (f3-f2)-(f0-f1); return P*llPow(t,3) + ((f0-f1)-P)*llPow(t,2) + (f2-f0)*t + f1; } </lsl>
Release to Public Domain. By Nexii Malthus
|
Vector Cubic | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Cubic interpolation of v0, v1, v2 and v3 with fraction t. <lsl> vector vCub(vector v0,vector v1,vector v2,vector v3,float t){ vector P = (v3-v2)-(v1-v0); return P*llPow(t,3) + ((v1-v0)-P)*llPow(t,2) + (v2-v1)*t + v0; } </lsl>
Released to Public Domain. By Nexii Malthus
|
Rotation Cubic | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Spherical Cubic interpolation of r0 and r1 with fraction t. I liken to call it as SCURP <lsl> rotation rCub(rotation r0,rotation r1,rotation r2,rotation r3,float t){ // Spherical-Cubic Interpolation // r0 = Start, r1 = End, r2 and r3 affect path of curve! return rLin( rLin(r0,r1,t), rLin(r2,r3,t), 2*t*(1-t) ); } </lsl>
Released to Public Domain. By Nexii Malthus
|