Difference between revisions of "Interpolation/Catmull-Rom"

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


== Catmull-Rom 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 Catmull-Rom===
|-
|
Catmull-Rom cubic interpolation spline of four floats with fraction t. The four floats are stored in a compact rotation format.
<lsl>
rotation mCat1 = <-0.5,  1.0, -0.5,  0.0>;
rotation mCat2 = < 1.5, -2.5,  0.0,  1.0>;
rotation mCat3 = <-1.5,  2.0,  0.5,  0.0>;
rotation mCat4 = < 0.5, -0.5,  0.0,  0.0>;
float fCatmullRom(rotation H, float t) {
    rotation ABCD = <
        (H.x * mCat1.x) + (H.y * mCat2.x) + (H.z * mCat3.x) + (H.s * mCat4.x),
        (H.x * mCat1.y) + (H.y * mCat2.y) + (H.z * mCat3.y) + (H.s * mCat4.y),
        (H.x * mCat1.z) + (H.y * mCat2.z) + (H.z * mCat3.z) + (H.s * mCat4.z),
        (H.x * mCat1.s) + (H.y * mCat2.s) + (H.z * mCat3.s) + (H.s * mCat4.s)
    >;
    rotation T; T.s = 1.0; T.z = t; T.y = T.z*T.z; T.x = T.y*T.z;
    return T.x*ABCD.x + T.y*ABCD.y + T.z*ABCD.z + T.s*ABCD.s;
}
</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
|-
| rotation H
| <float f0, float f1, float f2, float f3>
|-
| float t
| Fraction of interpolation
|-
!style="background-color: #d0d0ee" | Output
!style="background-color: #d0d0ee" | Description
|-
| return float fCatmullRom
| Returns Catmull-Rom cubic interpolation
|}
| Graph goes here, k.
|}
<div style="float:right;font-size: 80%;">
Released to Public Domain. By Nexii Malthus</div>
|}

Latest revision as of 04:06, 14 September 2011