Interpolation/Hermite
< Interpolation
Jump to navigation
Jump to search
Revision as of 14:02, 4 September 2011 by Nexii Malthus (talk | contribs) (Created page with "{{LSL Header|Interpolation}} {{RightToc|clear:right;}} == Hermite Interpolation == {|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1e…")
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | Interpolation |
Hermite Interpolation
Float Hermite | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hermite interpolation of f0, f1, f2 and f3 with fraction t, tension and bias. <lsl> float fHem(float f0,float f1,float f2,float f3,float t,float tens,float bias){ float t2 = t*t;float t3 = t2*t; float a0 = (f1-f0)*(1+bias)*(1-tens)/2; a0 += (f2-f1)*(1-bias)*(1-tens)/2; float a1 = (f2-f1)*(1+bias)*(1-tens)/2; a1 += (f3-f2)*(1-bias)*(1-tens)/2; float b0 = 2*t3 - 3*t2 + 1; float b1 = t3 - 2*t2 + t; float b2 = t3 - t2; float b3 = -2*t3 + 3*t2; return ( b0 * f1+b1 * a0+b2 * a1+b3 * f2 ); } </lsl>
Released to Public Domain. By Nexii Malthus
|
Vector Hermite | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hermite interpolation of v0, v1, v2 and v3 with fraction t, tension and bias. <lsl> vector vHem(vector v0,vector v1,vector v2,vector v3,float t,float tens,float bias){ float t2 = t*t;float t3 = t2*t; vector a0 = (v1-v0)*(1+bias)*(1-tens)/2; a0 += (v2-v1)*(1-bias)*(1-tens)/2; vector a1 = (v2-v1)*(1+bias)*(1-tens)/2; a1 += (v3-v2)*(1-bias)*(1-tens)/2; float b0 = 2*t3 - 3*t2 + 1; float b1 = t3 - 2*t2 + t; float b2 = t3 - t2; float b3 = -2*t3 + 3*t2; return ( b0 * v1+b1 * a0+b2 * a1+b3 * v2 );} </lsl>
Released to Public Domain. By Nexii Malthus
|