Difference between revisions of "Interpolation/Hermite"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "{{LSL Header|Interpolation}} {{RightToc|clear:right;}} == Hermite Interpolation == {|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1e…")
 
(Page not needed anymore.)
 
Line 1: Line 1:
{{LSL Header|[[Interpolation]]}}
{{RightToc|clear:right;}}


== Hermite Interpolation ==
{|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background-color: #ffffff; border-collapse: collapse" width="80%"
!style="color: #000000; background-color: #aaaaff;" height="20px"|
===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>
{|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background-color: #ffffff; border-collapse: collapse" width="80%"
|
{|cellspacing="0" cellpadding="6" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background-color: #e0e0ff; border-collapse: collapse"
!style="background-color: #d0d0ee" | Input
!style="background-color: #d0d0ee" | Description
|-
| float f0
| Modifier, 0.33~
|-
| float f1
| Start, 0.0
|-
| float f2
| End, 1.0
|-
| float f3
| Modifier, 0.66~
|-
| float t
| Fraction of interpolation
|-
| float tens
| Tension of interpolation
|-
| float bias
| Bias of interpolation
|-
!style="background-color: #d0d0ee" | Output
!style="background-color: #d0d0ee" | Description
|-
| return float fHem
| Returns hermite interpolation of four floats with tension and bias
|}
| Graph goes here, k.
|}
<div style="float:right;font-size: 80%;">
Released to Public Domain. By Nexii Malthus</div>
|}
{|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background-color: #ffffff; border-collapse: collapse" width="80%"
!style="color: #000000; background-color: #aaaaff;" height="20px"|
===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>
{|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background-color: #ffffff; border-collapse: collapse" width="80%"
|
{|cellspacing="0" cellpadding="6" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; background-color: #e0e0ff; border-collapse: collapse"
!style="background-color: #d0d0ee" | Input
!style="background-color: #d0d0ee" | Description
|-
| vector v0
| Modifier, 0.33~
|-
| vector v1
| Start, 0.0
|-
| vector v2
| End, 1.0
|-
| vector v3
| Modifier, 0.66~
|-
| float t
| Fraction of interpolation
|-
| float tens
| Tension of interpolation
|-
| float bias
| Bias of interpolation
|-
!style="background-color: #d0d0ee" | Output
!style="background-color: #d0d0ee" | Description
|-
| return vector vHem
| Returns hermite interpolation of four vectors with tension and bias
|}
| Graph goes here, k.
|}
<div style="float:right;font-size: 80%;">
Released to Public Domain. By Nexii Malthus</div>
|}

Latest revision as of 04:14, 14 September 2011