Namespace

DuMath

DuMath

Members

Number

# static readonly Location

Enum for locations.
Properties:
Name Type Description
TOP Number
TOP_RIGHT Number
RIGHT Number
BOTTOM_RIGHT Number
BOTTOM Number
BOTTOM_LEFT Number
LEFT Number
TOP_LEFT Number
CENTER Number

View Source Duik_api_fordoc.jsxinc, line 7352

Methods

# static angleFromSides(anglePoint, oppositePointA, oppositePointB) → {Number}

Finds the angle formed by three points
Parameters:
Name Type Description
anglePoint Array.<Number> The point at which to measure the angle
oppositePointA Array.<Number> One of the opposite points
oppositePointB Array.<Number> The other opposite point

View Source Duik_api_fordoc.jsxinc, line 8188

The angle in radians.
Number

# static average(values) → {float}

Calculates the average value in a list
Parameters:
Name Type Description
values Number | Array.<Number> values

View Source Duik_api_fordoc.jsxinc, line 7858

The average value
float

# static bounds(values) → {Array.<float>}

Gets the bounds of the values
Parameters:
Name Type Description
values Array.<Array.<Number>> A list of values

View Source Duik_api_fordoc.jsxinc, line 8109

The bounds, for N dimensions: [min1, min2, ..., minN, max1, max2, ..., maxN]
Array.<float>

# static clamp(values, minopt, maxopt) → {Number|Array.<Number>}

Clamps the value
Parameters:
Name Type Attributes Default Description
values Number | Array.<Number> values
min Number <optional>
0 The minimum value
max Number <optional>
1 The maximum value

View Source Duik_api_fordoc.jsxinc, line 7884

The clamped values
Number | Array.<Number>

# static equals(value1, value2, floatPrecisionopt) → {boolean}

Compares two numbers
Parameters:
Name Type Attributes Default Description
value1 Number | Array.<Number> The first value
value2 Number | Array.<Number> The second value
floatPrecision Number <optional>
9 The precision for (float) number comparison, number of decimals. Set to -1 to not use.

View Source Duik_api_fordoc.jsxinc, line 7813

true if the two values are equal
boolean

# static gaussian(value, minopt, maxopt, centeropt, fwhmopt) → {Number}

The gaussian function
Parameters:
Name Type Attributes Default Description
value Number The variable
min Number <optional>
0 The minimum return value
max Number <optional>
1 The maximum return value
center Number <optional>
0 The center of the peak
fwhm Number <optional>
1 The full width at half maximum of the curve

View Source Duik_api_fordoc.jsxinc, line 7978

The result
Number

# static gaussRandom(minopt, maxopt, boundedopt) → {int}

Generates a random integer between minimum and maximum.
The results are distributed along a gaussian (bell) curve.
Note that a few (< 10%) values may be outside of the range. Set the bounded to true to avoid that.
Parameters:
Name Type Attributes Default Description
min int <optional>
0 The minimum value
max int <optional>
1 The maximum value
bounded Bool <optional>
false When this is false, a few values may be outside the range. Set it to true to make sure all values are between min and max.

View Source Duik_api_fordoc.jsxinc, line 7742

The randomly generated integer
int

# static inverseGaussian(v, minopt, maxopt, centeropt, fwhmopt) → {Array.<Number>}

The inverse gaussian function
Parameters:
Name Type Attributes Default Description
v Number The variable
min Number <optional>
0 The minimum return value of the corresponding gaussian function
max Number <optional>
1 The maximum return value of the corresponding gaussian function
center Number <optional>
0 The center of the peak of the corresponding gaussian function
fwhm Number <optional>
1 The full width at half maximum of the curve of the corresponding gaussian function

View Source Duik_api_fordoc.jsxinc, line 8016

The two possible results, the lower is the first in the list. If both are the same, it is the maximum
Array.<Number>

# static inverseLogistic(v, midValueopt, minopt, maxopt, rateopt) → {Number}

The inverse logistic function (inverse sigmoid)
Parameters:
Name Type Attributes Default Description
v Number The variable
midValue Number <optional>
0 The midpoint value, at which the function returns max/2 in the original logistic function
min Number <optional>
0 The minimum return value of the original logistic function
max Number <optional>
1 The maximum return value of the original logistic function
rate Number <optional>
1 The logistic growth rate or steepness of the original logistic function

View Source Duik_api_fordoc.jsxinc, line 7958

The result
Number

# static inverseReversedGaussian(value, minopt, maxopt, centeropt, fwhmopt) → {Array.<Number>}

The inverse of the reversed gaussian function
Parameters:
Name Type Attributes Default Description
value Number The variable
min Number <optional>
0 The minimum return value of the corresponding gaussian function
max Number <optional>
1 The maximum return value of the corresponding gaussian function
center Number <optional>
0 The center of the peak of the corresponding gaussian function
fwhm Number <optional>
1 The full width at half maximum of the curve of the corresponding gaussian function

View Source Duik_api_fordoc.jsxinc, line 8041

The two possible results, the lower is the first in the list. If both are the same, it is the maximum
Array.<Number>

# static isExtremePoint(previousValue, point, nextValue, precisionopt) → {Boolean}

Checks if the direction changes (if the point is at an extreme value). If the values have multiple dimensions, checks each axis individually.
Parameters:
Name Type Attributes Default Description
previousValue Number | Array.<Number> The value just before the point.
point Number | Array.<Number> The point to check.
nextValue Number | Array.<Number> The value just after the point.
precision int <optional>
1 The precision for floating point comparisons; number of decimals.

View Source Duik_api_fordoc.jsxinc, line 8135

Boolean

# static isInflexionPoint(previousVelocity, pointVelocity, nextVelocity) → {Boolean}

Checks if the point is an inflexion point.
Parameters:
Name Type Description
previousVelocity Number | Array.<Number> The derivative (speed) of a point just before the point.
pointVelocity Number | Array.<Number> The derivative (speed) at the point to check.
nextVelocity Number | Array.<Number> The derivative (speed) of a point just after the point.

View Source Duik_api_fordoc.jsxinc, line 8165

Boolean

# static isInside(point, bounds) → {Boolean}

Checks if a point is located inside given bounds
Parameters:
Name Type Description
point Array.<float> The point
bounds Array.<float> The bounds. The number of bounds must be at least twice the number of dimensions, in this order : [a1, a2, ..., x1,x2,y1,y2,z1,z2]

View Source Duik_api_fordoc.jsxinc, line 8081

true if the point is inside the bounds
Boolean

# static isLocationBottom(location) → {boolean}

Checks if the given location is on the bottom side
Parameters:
Name Type Description
location DuMath.Location The location

View Source Duik_api_fordoc.jsxinc, line 7684

boolean

# static isLocationHCenter(location) → {boolean}

Checks if the given location is on the center on the horizontal axis
Parameters:
Name Type Description
location DuMath.Location The location

View Source Duik_api_fordoc.jsxinc, line 7636

boolean

# static isLocationLeft(location) → {boolean}

Checks if the given location is on the left side
Parameters:
Name Type Description
location DuMath.Location The location

View Source Duik_api_fordoc.jsxinc, line 7648

boolean

# static isLocationRight(location) → {boolean}

Checks if the given location is on the right side
Parameters:
Name Type Description
location DuMath.Location The location

View Source Duik_api_fordoc.jsxinc, line 7624

boolean

# static isLocationTop(location) → {boolean}

Checks if the given location is on the top side
Parameters:
Name Type Description
location DuMath.Location The location

View Source Duik_api_fordoc.jsxinc, line 7660

boolean

# static isLocationVCenter(location) → {boolean}

Checks if the given location is on the center on the vertical axis
Parameters:
Name Type Description
location DuMath.Location The location

View Source Duik_api_fordoc.jsxinc, line 7672

boolean

# static length(value1, value2opt) → {number}

Measures the vector length between two points
Parameters:
Name Type Attributes Default Description
value1 number | Array.<number> The first value
value2 number | Array.<number> <optional>
[0,0] The second value. If omitted, returns the difference between the two first values of value1

View Source Duik_api_fordoc.jsxinc, line 7777

The length
number

# static linear(value, minopt, maxopt, targetMinopt, targetMaxopt, clampopt) → {Number}

The linear function
Parameters:
Name Type Attributes Default Description
value Number The variable
min Number <optional>
0 The minimum input value
max Number <optional>
1 The maximum input value
targetMin Number <optional>
0 The minimum output value
targetMax Number <optional>
1 The maximum output value
clamp Boolean <optional>
false Whether to clamp the output value to the target or not.

View Source Duik_api_fordoc.jsxinc, line 8056

Number

# static log10(w) → {float}

Calculates the log10 of a number
Parameters:
Name Type Description
w float The number

View Source Duik_api_fordoc.jsxinc, line 7848

The result of log10(x)
i.e. Math.log(x)/Math.LN10
float

# static logistic(value, midValueopt, minopt, maxopt, rateopt) → {Number}

The logistic function (sigmoid)
Parameters:
Name Type Attributes Default Description
value Number The value
midValue Number <optional>
0 The midpoint value, at which the function returns max/2
min Number <optional>
0 The minimum return value
max Number <optional>
1 The maximum return value
rate Number <optional>
1 The logistic growth rate or steepness of the function

View Source Duik_api_fordoc.jsxinc, line 7939

The result in the range [min, max] (excluding min and max)
Number

# static random(minopt, maxopt) → {int}

Generates a random integer between minimum and maximum
Parameters:
Name Type Attributes Default Description
min int <optional>
0 The minimum value
max int <optional>
1 The maximum value

View Source Duik_api_fordoc.jsxinc, line 7719

The randomly generated integer
int

# static relativeLocation(point, originopt) → {DuMath.Location}

Returns the location of the point relative to the origin. Works with 2D values, the first two coordinates. Considers the coordinate [0,0] to be the top left corner of the system: positive values are right, bottom
Parameters:
Name Type Attributes Default Description
point Array.<float> The point to check
origin Array.<float> <optional>
[0,0] The coordinates of the origin

View Source Duik_api_fordoc.jsxinc, line 7698

The location

# static reversedGaussian(value, minopt, maxopt, centeropt, fwhmopt) → {Number}

A "reversed" gaussian function, growing faster with low value
Parameters:
Name Type Attributes Default Description
value Number The variable
min Number <optional>
0 The minimum return value
max Number <optional>
1 The maximum return value
center Number <optional>
0 The center of the peak
fwhm Number <optional>
1 The full width at half maximum of the curve

View Source Duik_api_fordoc.jsxinc, line 8002

The result
Number

# static sign(num) → {Number}

Checks the sign of a number
Parameters:
Name Type Description
num Number The number to check

View Source Duik_api_fordoc.jsxinc, line 8098

1 if num is positive, -1 if negative, 0 in other cases (0, NaN...)
Number

# static toDegrees(value) → {float}

Converts the number from radians to degrees
Parameters:
Name Type Description
value number the value

View Source Duik_api_fordoc.jsxinc, line 7926

The value in degrees
float

# static toRadians(value) → {float}

Converts the number from degrees to radians
Parameters:
Name Type Description
value number the value

View Source Duik_api_fordoc.jsxinc, line 7916

The value in radians
float

# static zero(dimensions) → {Array.<number>}

Generates a zero value
Parameters:
Name Type Description
dimensions number The number of needed dimensions

View Source Duik_api_fordoc.jsxinc, line 7763

Zero [0, ..., 0]
Array.<number>