ig.

utilsmath

Static utilities for math.

Author:
  • Collin Hover - collinhover.com
Source:

<static> GOLDEN_ANGLE :number

Constant: golden angle.

Source:

<static> HALFPI :number

Constant: half pi.

Source:

<static> TWOPI :number

Constant: 2pi.

Source:

<static> almostEqual(a, b, threshold) → {Boolean}

Checks two numbers to see if almost equal.
- this is particularly useful for physics systems that make small steps

Parameters:
Name Type Description
a Number number a
b Number number b
threshold Number threshold beyond which numbers are not considered equal
Source:
Returns:
{ Boolean } true if numbers are within threshold of each other

<static> clamp(n, min, max) → {Number}

Clamps a number between and min and max.

Parameters:
Name Type Description
n Number number.
min Number min value.
max Number max value.
Source:
Returns:
{ Number } limited number

<static> degreesToRadians(n) → {Number}

Converts degrees to radians,

Parameters:
Name Type Description
n Number degress.
Source:
Returns:
{ Number } radians

<static> direction(n) → {Number}

Checks the direction of a number.

Parameters:
Name Type Description
n Number number.
Source:
Returns:
{ Number } -1, 0, or 1

<static> directionChange(a, b) → {Boolean}

Checks two numbers to see if a change in direction has occured.

Parameters:
Name Type Description
a Number number a.
b Number number b.
Source:
Returns:
{ Boolean } true if numbers are on opposite sides of zero, or one is 0 and other is not

<static> map(n, istart, istop, ostart, ostop) → {Number}

Maps an interval number to start and stop values.

Parameters:
Name Type Description
n Number number.
istart Number interval start.
istop Number interval stop.
ostart Number start.
ostop Number stop.
Source:
Returns:
{ Number } mapped number

<static> oppositeSidesOfZero(a, b) → {Boolean}

Checks two numbers to see if on opposite sides of zero.

Parameters:
Name Type Description
a Number number a.
b Number number b.
Source:
Returns:
{ Boolean } true if numbers are on opposite sides of zero

<static> radiansToDegrees(n) → {Number}

Converts radians to degress,

Parameters:
Name Type Description
n Number radians.
Source:
Returns:
{ Number } degrees