/*jslint plusplus: true, white: true, indent: 2, maxlen: 90 */
/*global HTMLCanvasElement, document */
/**
* @author Wolfgang Kowarschick
* @copyright 2013, Wolfgang Kowarschick
* <br/>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted under the terms of the
* Creative Commons License Attribution-NonCommercial-ShareAlike 3.0 Unported
* (CC BY-NC-SA 3.0: http://creativecommons.org/licenses/by-nc-sa/3.0/).
*/
(function($wk$)
{ "use strict";
////////////////////////////////////////////////////////////////////////////////
// Class "Math"
////////////////////////////////////////////////////////////////////////////////
/**
* @class
* @name $wk$.Math
*/
/**
* Computes a random integer number within an interval.
* @method
* @name $wk$.Math.randomInt
* @param {Number | Array<Number>} p_interval
* @returns An integer number within the interval
* [<code>p_interval[0]</code>, <code>p_interval[1]</code>].
*/
Math.randomInt =
function(p_interval)
{ if (p_interval instanceof Array)
{ var l_min = p_interval[0], l_max = p_interval[1];
return l_min+Math.floor(Math.random()*(l_max-l_min+1));
}
else
{ return Math.floor(p_interval); }
};
/**
* Computes a random number within an interval.
* @method
* @name $wk$.Math.randomNum
* @param {Number | Array<Number>} p_interval
* @returns A number within the interval
* [<code>p_interval[0]</code>, <code>p_interval[1]</code>].
*/
Math.randomNum =
function(p_interval)
{ if (p_interval instanceof Array)
{ var l_min = p_interval[0], l_max = p_interval[1];
return l_min+Math.random()*(l_max-l_min);
}
else
{ return p_interval; }
};
$wk$.Math = Math;
////////////////////////////////////////////////////////////////////////////////
//End of Class "Math"
////////////////////////////////////////////////////////////////////////////////
}(this.$wk$));