Difference between revisions of "Interpolation/Catmull-Rom/Float"
< Interpolation | Catmull-Rom
Jump to navigation
Jump to search
(Created page with "{{LSL_Function |mode=user |func=fCos |p1_type=rotation|p1_name=H|p1_desc=The four floats are stored in a compact rotation format. |p2_type=float|p2_name=t |return_type=float |ret…") |
m (<lsl> tag to <source>) |
||
Line 8: | Line 8: | ||
|func_desc= | |func_desc= | ||
Catmull-Rom cubic interpolation spline of four floats with fraction t. | Catmull-Rom cubic interpolation spline of four floats with fraction t. | ||
|spec=A bit more optimised:< | |spec=A bit more optimised:<source lang="lsl2">float fCatmullRom(rotation H, float t) { | ||
rotation ABCD = < | rotation ABCD = < | ||
(H.x *-0.5) + (H.y * 1.5) + (H.z *-1.5) + (H.s * 0.5), | (H.x *-0.5) + (H.y * 1.5) + (H.z *-1.5) + (H.s * 0.5), | ||
Line 17: | Line 17: | ||
return T.x*ABCD.x + T.y*ABCD.y + T.z*ABCD.z + T.s*ABCD.s; | return T.x*ABCD.x + T.y*ABCD.y + T.z*ABCD.z + T.s*ABCD.s; | ||
} | } | ||
// Released into public domain. By Nexii Malthus.</ | // Released into public domain. By Nexii Malthus.</source> | ||
With full matrix: | With full matrix: | ||
< | <source lang="lsl2">rotation mCat1 = <-0.5, 1.0, -0.5, 0.0>; | ||
rotation mCat2 = < 1.5, -2.5, 0.0, 1.0>; | rotation mCat2 = < 1.5, -2.5, 0.0, 1.0>; | ||
rotation mCat3 = <-1.5, 2.0, 0.5, 0.0>; | rotation mCat3 = <-1.5, 2.0, 0.5, 0.0>; | ||
Line 34: | Line 34: | ||
return T.x*ABCD.x + T.y*ABCD.y + T.z*ABCD.z + T.s*ABCD.s; | return T.x*ABCD.x + T.y*ABCD.y + T.z*ABCD.z + T.s*ABCD.s; | ||
} | } | ||
// Released into public domain. By Nexii Malthus.</ | // Released into public domain. By Nexii Malthus.</source> | ||
|examples=< | |examples=<source lang="lsl2"></source> | ||
|cat1=Examples | |cat1=Examples | ||
}} | }} |
Latest revision as of 15:00, 24 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: float fCos( rotation H, float t );
Catmull-Rom cubic interpolation spline of four floats with fraction t.
Returns a float
• rotation | H | – | The four floats are stored in a compact rotation format. | |
• float | t |
Specification
A bit more optimised:
float fCatmullRom(rotation H, float t) {
rotation ABCD = <
(H.x *-0.5) + (H.y * 1.5) + (H.z *-1.5) + (H.s * 0.5),
(H.x * 1.0) + (H.y *-2.5) + (H.z * 2.0) + (H.s *-0.5),
(H.x *-0.5) + (H.z * 0.5), (H.y * 1.0)
>;
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;
}
// Released into public domain. By Nexii Malthus.
With full matrix:
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;
}
// Released into public domain. By Nexii Malthus.
Examples