Interpolation/Rescale
< Interpolation
Jump to navigation
Jump to search
Revision as of 14:18, 4 September 2011 by Nexii Malthus (talk | contribs) (Created page with "{{LSL Header|Interpolation}} {{RightToc|clear:right;}} == Rescale == {|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt;…")
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | Interpolation |
Rescale
Float Rescale | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Rescales a value from one range to another range. <lsl> float fScl(float from0, float from1, float to0, float to1, float t) { return to0 + ( (to1 - to0) * ( (from0 - t) / (from0-from1) ) ); } </lsl>
Released to Public Domain. By Nexii Malthus
|
Float Rescale Fixed | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Rescales a value from one range to another range. The value is clamped between the range. <lsl> float fSclFix(float from0, float from1, float to0, float to1, float t) { t = to0 + ( (to1 - to0) * ( (from0 - t) / (from0-from1) ) ); if(to0 < to1) { if(t < to0) t = to0; else if(t > to1) t = to1; } else { if(t < to1) t = to1; else if(t > to0) t = to0; } return t; } </lsl>
Released to Public Domain. By Nexii Malthus
|