Difference between revisions of "Interpolation/Rescale/Float"
< Interpolation | Rescale
Jump to navigation
Jump to search
Line 2: | Line 2: | ||
|mode=user | |mode=user | ||
|func=fScl | |func=fScl | ||
|p1_type=float|p1_name= | |p1_type=float|p1_name=from_min|p1_desc=Minimum of range From | ||
|p2_type=float|p2_name= | |p2_type=float|p2_name=from_max|p2_desc=Maximum of range From | ||
|p3_type=float|p3_name= | |p3_type=float|p3_name=to_min|p3_desc=Minimum of range To | ||
|p4_type=float|p4_name= | |p4_type=float|p4_name=to_max|p4_desc=Maximum of range To | ||
|p5_type=float|p5_name=from | |p5_type=float|p5_name=from|p5_desc=Value in range From | ||
|return_type=float | |return_type=float | ||
|return_value=returns rescaled value | |return_value=returns rescaled value |
Revision as of 03:24, 14 September 2011
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: float fScl( float from_min, float from_max, float to_min, float to_max, float from );
Rescales a value from one range to another range.
Returns a float
• float | from_min | – | Minimum of range From | |
• float | from_max | – | Maximum of range From | |
• float | to_min | – | Minimum of range To | |
• float | to_max | – | Maximum of range To | |
• float | from | – | Value in range 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>