Difference between revisions of "Interpolation/Rescale/Float"
< Interpolation | Rescale
Jump to navigation
Jump to search
(Created page with "{{LSL_Function |mode=user |func=fLin |p1_type=float|p1_name=from_a |p2_type=float|p2_name=from_b |p3_type=float|p3_name=to_a |p4_type=float|p4_name=to_b |p5_type=float|p5_name=fr…") |
|||
Line 1: | Line 1: | ||
{{LSL_Function | {{LSL_Function | ||
|mode=user | |mode=user | ||
|func= | |func=fScl | ||
|p1_type=float|p1_name=from_a | |p1_type=float|p1_name=from_a | ||
|p2_type=float|p2_name=from_b | |p2_type=float|p2_name=from_b |
Revision as of 03:23, 14 September 2011
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: float fScl( float from_a, float from_b, float to_a, float to_b, float from );
Rescales a value from one range to another range.
Returns a float
• float | from_a | |||
• float | from_b | |||
• float | to_a | |||
• float | to_b | |||
• float | from |
Specification
<lsl>float fScl(float from_min, float from_max, float to_min, float to_max, float from) {
return to_min + ((to_max-to_min) * ((from_min-from) / (from_min-from_max)));
} // Released into public domain. By Nexii Malthus.</lsl>
Examples
<lsl>float value = fScl(0.0, 1.0, -5, 15, 0.6); // value == 7</lsl>