Skip to main content
Version: Phaser v4.0.0

Phaser.Math.Fuzzy

Scope: static

Source: src/math/fuzzy/index.js#L7

Static functions

Ceil

<static> Ceil(value, [epsilon])

Description:

Calculate the fuzzy ceiling of the given value.

Rounds the value up to the nearest integer, but subtracts a small epsilon tolerance before applying Math.ceil. This means that values very slightly above an integer boundary (within the epsilon range) are treated as if they were exactly on that boundary, avoiding floating-point precision errors that would otherwise push the result up to the next integer unexpectedly.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe value to compute the fuzzy ceiling of.
epsilonnumberYes0.0001The epsilon tolerance used to reduce floating-point precision errors.

Returns: number - The fuzzy ceiling of the value.

Source: src/math/fuzzy/Ceil.js#L7
Since: 3.0.0


Equal

<static> Equal(a, b, [epsilon])

Description:

Check whether the given values are fuzzily equal.

Two numbers are fuzzily equal if their difference is less than epsilon.

Parameters:

nametypeoptionaldefaultdescription
anumberNoThe first value.
bnumberNoThe second value.
epsilonnumberYes0.0001The maximum absolute difference below which the two values are considered equal.

Returns: boolean - true if the values are fuzzily equal, otherwise false.

Source: src/math/fuzzy/Equal.js#L7
Since: 3.0.0


Floor

<static> Floor(value, [epsilon])

Description:

Calculates the fuzzy floor of the given value by adding a small epsilon before flooring. This avoids floating-point precision issues where a value that should mathematically be an integer (e.g. 2.9999999) floors incorrectly to the integer below. Any value within epsilon of the next integer up will be floored to that integer.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe value to calculate the fuzzy floor of.
epsilonnumberYes0.0001The epsilon value. Values within this distance of the next integer up are floored to that integer.

Returns: number - The fuzzy floor of the given value.

Source: src/math/fuzzy/Floor.js#L7
Since: 3.0.0


GreaterThan

<static> GreaterThan(a, b, [epsilon])

Description:

Check whether a is fuzzily greater than b.

a is fuzzily greater than b if it is more than b - epsilon.

Parameters:

nametypeoptionaldefaultdescription
anumberNoThe first value.
bnumberNoThe second value.
epsilonnumberYes0.0001The epsilon value used to control the degree of fuzziness. A larger value makes the comparison more lenient.

Returns: boolean - true if a is fuzzily greater than b, otherwise false.

Source: src/math/fuzzy/GreaterThan.js#L7
Since: 3.0.0


LessThan

<static> LessThan(a, b, [epsilon])

Description:

Check whether a is fuzzily less than b.

a is fuzzily less than b if it is less than b + epsilon.

Parameters:

nametypeoptionaldefaultdescription
anumberNoThe first value.
bnumberNoThe second value.
epsilonnumberYes0.0001The tolerance value used for the fuzzy comparison. Values within this distance are considered equal.

Returns: boolean - true if a is fuzzily less than b, otherwise false.

Source: src/math/fuzzy/LessThan.js#L7
Since: 3.0.0