Namespace

DuMath

DuMath

Math related methods

View Source DuAEF.jsxinc, line 6901

Members

int

# static readonly Location

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

View Source DuAEF.jsxinc, line 6909

Methods

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

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

View Source DuAEF.jsxinc, line 7463

The angle in radians.
float

# static average(values) → {float}

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

View Source DuAEF.jsxinc, line 7133

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 DuAEF.jsxinc, line 7384

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 DuAEF.jsxinc, line 7159

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 int <optional>
-1 The precision for (float) number comparison, number of decimals. Set to -1 to not use.

View Source DuAEF.jsxinc, line 7088

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 DuAEF.jsxinc, line 7253

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 DuAEF.jsxinc, line 7044

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 DuAEF.jsxinc, line 7291

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 DuAEF.jsxinc, line 7233

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 DuAEF.jsxinc, line 7316

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 DuAEF.jsxinc, line 7410

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 DuAEF.jsxinc, line 7440

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 DuAEF.jsxinc, line 7356

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 DuAEF.jsxinc, line 6986

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 DuAEF.jsxinc, line 6938

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 DuAEF.jsxinc, line 6950

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 DuAEF.jsxinc, line 6926

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 DuAEF.jsxinc, line 6962

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 DuAEF.jsxinc, line 6974

boolean

# static length(value1, value2) → {float}

Measures the vector length between two points
Parameters:
Name Type Description
value1 Array.<int> The first value
value2 Array.<int> The second value

View Source DuAEF.jsxinc, line 7066

The length
float

# 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 DuAEF.jsxinc, line 7331

Number

# static log10(w) → {float}

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

View Source DuAEF.jsxinc, line 7123

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 DuAEF.jsxinc, line 7214

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

# static mean()

Alias for DuMath.average.

View Source DuAEF.jsxinc, line 7149

# 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 DuAEF.jsxinc, line 7021

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 DuAEF.jsxinc, line 7000

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 DuAEF.jsxinc, line 7277

The result
Number

# static sign(num) → {int}

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

View Source DuAEF.jsxinc, line 7373

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

# static toDegrees(value) → {float}

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

View Source DuAEF.jsxinc, line 7201

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 DuAEF.jsxinc, line 7191

The value in radians
float