linearConversion

From Bohemia Interactive Community
Revision as of 23:39, 20 March 2016 by Killzone Kid (talk | contribs) (example)
Jump to navigation Jump to search
Hover & click on the images for description

Description

Description:
Converts value in interval [min, max] to newMin + a * (max - min) / (newMax - newMin), potentially clamps the final value.
Groups:
Uncategorised

Syntax

Syntax:
linearConversion [min, max, value, newMin, newMax, clamp]
Parameters:
[min, max, value, newMin, newMax, clamp]: Array
min: Number
max: Number
value: Number
newMin: Number
newMax: Number
clamp (optional): Boolean (Default is false)
Return Value:
Number

Examples

Example 1:
linearConversion [4, 8, 5, 0, 1, false];
Example 2:
Calculate days from 1/1/1970: fnc_daysFromEpoc = { private _year = param [0]; private _days = 0; for "_i" from 1970 to _year - 1 do { _days = _days + round linearConversion [0, 1, dateToNumber [_i, 12, 31, 23, 59], 0, 365, false]; }; _days + linearConversion [0, 1, dateToNumber _this, 0, 365, false]; }; hint str (date call fnc_daysFromEpoc);

Additional Information

See also:
See also needed

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Posted on Mar 29, 2014 - 09:39
ffur2007slx2_5
(A3 0.50) It is recommended to use linearConversion instead of BIS_fnc_linearConversion: linearConversion [0,100,50,0,50,true ]; //same as [[0,100],50,[0,50]] call BIS_fnc_linearConversion As for clamp, true will disable new value out of its range while false won't: linearConversion [0,100,150,0,50,true ]; //return 50 linearConversion [0,100,150,0,50,false ]; //return 75

Bottom Section