Skip to content

Commit 5e374b2

Browse files
committed
Elaborated fuzzy math function descriptions.
Finished up pow2 and RandomDataGenerator descriptions.
1 parent 0f9bfc6 commit 5e374b2

7 files changed

Lines changed: 25 additions & 20 deletions

File tree

src/math/fuzzy/Ceil.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
*/
66

77
/**
8-
* Calculate the ceiling of the given value.
8+
* Calculate the fuzzy ceiling of the given value.
99
*
1010
* @function Phaser.Math.Fuzzy.Ceil
1111
* @since 3.0.0
1212
*
1313
* @param {number} value - The value.
1414
* @param {float} [epsilon=0.0001] - The epsilon.
1515
*
16-
* @return {number} The ceiling of the value.
16+
* @return {number} The fuzzy ceiling of the value.
1717
*/
1818
var Ceil = function (value, epsilon)
1919
{

src/math/fuzzy/Equal.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
/**
8-
* Check whether the given values are equal.
8+
* Check whether the given values are fuzzily equal.
9+
*
10+
* Two numbers are fuzzily equal if their difference is less than `epsilon`.
911
*
1012
* @function Phaser.Math.Fuzzy.Equal
1113
* @since 3.0.0
@@ -14,7 +16,7 @@
1416
* @param {number} b - The second value.
1517
* @param {float} [epsilon=0.0001] - The epsilon.
1618
*
17-
* @return {boolean} Whether the given values are equal.
19+
* @return {boolean} `true` if the values are fuzzily equal, otherwise `false`.
1820
*/
1921
var Equal = function (a, b, epsilon)
2022
{

src/math/fuzzy/Floor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
/**
8-
* Calculate the floor of the given value.
8+
* Calculate the fuzzy floor of the given value.
99
*
1010
* @function Phaser.Math.Fuzzy.Floor
1111
* @since 3.0.0

src/math/fuzzy/GreaterThan.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
/**
8-
* Check whether `a` is greater than `b`.
8+
* Check whether `a` is fuzzily greater than `b`.
9+
*
10+
* `a` is fuzzily greater than `b` if it is more than `b - epsilon`.
911
*
1012
* @function Phaser.Math.Fuzzy.GreaterThan
1113
* @since 3.0.0
@@ -14,7 +16,7 @@
1416
* @param {number} b - The second value.
1517
* @param {float} [epsilon=0.0001] - The epsilon.
1618
*
17-
* @return {boolean} Whether `a` is greater than `b`.
19+
* @return {boolean} `true` if `a` is fuzzily greater than than `b`, otherwise `false`.
1820
*/
1921
var GreaterThan = function (a, b, epsilon)
2022
{

src/math/fuzzy/LessThan.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
/**
8-
* Check whether `a` is less than `b`.
8+
* Check whether `a` is fuzzily less than `b`.
9+
*
10+
* `a` is fuzzily less than `b` if it is less than `b + epsilon`.
911
*
1012
* @function Phaser.Math.Fuzzy.LessThan
1113
* @since 3.0.0
@@ -14,7 +16,7 @@
1416
* @param {number} b - The second value.
1517
* @param {float} [epsilon=0.0001] - The epsilon.
1618
*
17-
* @return {boolean} Whether `a` is less than `b`.
19+
* @return {boolean} `true` if `a` is fuzzily less than `b`, otherwise `false`.
1820
*/
1921
var LessThan = function (a, b, epsilon)
2022
{

src/math/pow2/GetPowerOfTwo.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
* @function Phaser.Math.Pow2.GetPowerOfTwo
1111
* @since 3.0.0
1212
*
13-
* @param {number} value - [description]
13+
* @param {number} value - The value.
1414
*
15-
* @return {integer} [description]
15+
* @return {integer} The nearest power of 2 to `value`.
1616
*/
1717
var GetPowerOfTwo = function (value)
1818
{
19-
// Math.log(2)
2019
var index = Math.log(value) / 0.6931471805599453;
2120

2221
return (1 << Math.ceil(index));

src/math/random-data-generator/RandomDataGenerator.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ var Class = require('../../utils/Class');
88

99
/**
1010
* @classdesc
11-
* [description]
11+
* A seeded random data generator.
1212
*
1313
* @class RandomDataGenerator
1414
* @memberOf Phaser.Math
1515
* @constructor
1616
* @since 3.0.0
1717
*
18-
* @param {string[]} [seeds] - [description]
18+
* @param {string[]} [seeds] - The seeds.
1919
*/
2020
var RandomDataGenerator = new Class({
2121

@@ -79,7 +79,7 @@ var RandomDataGenerator = new Class({
7979
this.n = 0;
8080

8181
/**
82-
* [description]
82+
* Signs to choose from.
8383
*
8484
* @name Phaser.Math.RandomDataGenerator#signs
8585
* @type {number[]}
@@ -100,7 +100,7 @@ var RandomDataGenerator = new Class({
100100
* @since 3.0.0
101101
* @private
102102
*
103-
* @return {number} [description]
103+
* @return {number} A random number.
104104
*/
105105
rnd: function ()
106106
{
@@ -121,7 +121,7 @@ var RandomDataGenerator = new Class({
121121
* @since 3.0.0
122122
* @private
123123
*
124-
* @param {string} data - [description]
124+
* @param {string} data - The value to hash.
125125
*
126126
* @return {number} The hashed value.
127127
*/
@@ -150,12 +150,12 @@ var RandomDataGenerator = new Class({
150150
},
151151

152152
/**
153-
* [description]
153+
* Initialize the state of the random data generator.
154154
*
155155
* @method Phaser.Math.RandomDataGenerator#init
156156
* @since 3.0.0
157157
*
158-
* @param {(string|string[])} seeds - [description]
158+
* @param {(string|string[])} seeds - The seeds to initialize the random data generator with.
159159
*/
160160
init: function (seeds)
161161
{
@@ -456,7 +456,7 @@ var RandomDataGenerator = new Class({
456456
*
457457
* @method Phaser.Math.RandomDataGenerator#shuffle
458458
* @since 3.7.0
459-
*
459+
*
460460
* @param {array} [array] - The array to be shuffled.
461461
*
462462
* @return {array} The shuffled array.

0 commit comments

Comments
 (0)