Namespace: math

rat. math

Namespace for math functions
Source:

Members

(static, constant) DegreesToRadians

Source:

(static, constant) E

Source:

(static, constant) HALFPI

Source:

(static, constant) MAX_NUMBER

Source:

(static, constant) MIN_NUMBER

Source:

(static, constant) PI

Source:

(static, constant) PI2

Source:

(static, constant) TAU

Source:

Methods

(static) clamp(a, low, high) → {number}

Clamps to make sure that low <= a <= high
Parameters:
Name Type Description
a number the given value
low number the low clamp level
high number the high clamp level
Source:
Returns:
a the clamped value
Type
number

(static) findAngleOnCircle(x, y, centerX, centerY) → {number}

Finds the center of a circle.
Parameters:
Name Type Description
x number x-coordinate of a point on the circle.
y number y-coordinate of a point on the circle.
centerX number x-coordinate of the circle's center.
centerY number y-coordinate of the circle's center.
Source:
Returns:
The angle of the circle from the x-axis in radians.
Type
number

(static) findArcFromThreePoints(x1, y1, x2, y2, x3, y3) → {Object|Object}

Finds the arc which passes through three points. The ends are at point 1 and point 3.
Parameters:
Name Type Description
x1 number x-coordinate of point 1 on the circle.
y1 number y-coordinate of point 1 on the circle.
x2 number x-coordinate of point 2 on the circle.
y2 number y-coordinate of point 2 on the circle.
x3 number x-coordinate of point 3 on the circle.
y3 number y-coordinate of point 3 on the circle.
Source:
Returns:
Represents the arc or strait line if the three points line up.
Type
Object | Object

(static) findArcFromTwoPoints(x1, y1, x2, y2, radius, centerDirectionXnullable, centerDirectionYnullable) → {Object}

Finds the arc which passes through two points.
Parameters:
Name Type Attributes Description
x1 number x-coordinate of a point on the circle.
y1 number y-coordinate of a point on the circle.
x2 number x-coordinate of the other point on the circle.
y2 number y-coordinate of the other point on the circle.
radius number of the circle.
centerDirectionX number <nullable>
The desired direction of the center on the x-axis. Defaults to 1.
centerDirectionY number <nullable>
The desired direction of the center on the y-axis. Defaults to 1.
Source:
Returns:
Represents the arc.
Type
Object

(static) findArcOnCircle(x1, y1, x2, y2, centerX, centerY, radius) → {Object}

Finds the arc which passes through two points.
Parameters:
Name Type Description
x1 number x-coordinate of a point on the circle.
y1 number y-coordinate of a point on the circle.
x2 number x-coordinate of the other point on the circle.
y2 number y-coordinate of the other point on the circle.
centerX number x-coordinate of the circle's center.
centerY number y-coordinate of the circle's center.
radius number of the circle.
Source:
Returns:
Represents the arc.
Type
Object

(static) findCircleCenterFromTwoPoints(x1, y1, x2, y2, radius, centerDirectionXnullable, centerDirectionYnullable) → {Object}

Finds the center of a circle.
Parameters:
Name Type Attributes Description
x1 number x-coordinate of a point on the circle.
y1 number y-coordinate of a point on the circle.
x2 number x-coordinate of the other point on the circle.
y2 number y-coordinate of the other point on the circle.
radius number of the circle.
centerDirectionX number <nullable>
The desired direction of the center on the x-axis. Defaults to 1.
centerDirectionY number <nullable>
The desired direction of the center on the y-axis. Defaults to 1.
Source:
Returns:
The point of the circle's center.
Type
Object

(static) findCircleFromThreePoints(x1, y1, x2, y2, x3, y3) → {Object|boolean}

Finds the center of a circle.
Parameters:
Name Type Description
x1 number x-coordinate of point 1 on the circle.
y1 number y-coordinate of point 1 on the circle.
x2 number x-coordinate of point 2 on the circle.
y2 number y-coordinate of point 2 on the circle.
x3 number x-coordinate of point 3 on the circle.
y3 number y-coordinate of point 3 on the circle.
Source:
Returns:
The point of the circle's center or false if the points are a strait line.
Type
Object | boolean

(static) findPerpendicularBisector(x1, y1, x2, y2) → {Object}

Finds the perpendicular bisector of two points.
Parameters:
Name Type Description
x1 number x-coordinate of point 1 on the circle.
y1 number y-coordinate of point 1 on the circle.
x2 number x-coordinate of point 2 on the circle.
y2 number y-coordinate of point 2 on the circle.
Source:
Returns:
the perpendicular bisector in the form of ax+by=c.
Type
Object

(static) interp(valA, valB, interp) → {number}

Interpolate between two numbers interp = 0 -> valA | interp = 1 -> valB
Parameters:
Name Type Description
valA number
valB number
interp number 0.0 - 1.0
Source:
Returns:
[valA, valB]
Type
number

(static) randomRange()

random value min >= value >= max
Source:

(static) randomVariance(v) → {number}

Return a variance of +- v
Parameters:
Name Type Description
v number
Source:
Returns:
[-v, v]
Type
number

(static) signOf(num) → {number}

Get the sign of a number
Parameters:
Name Type Description
num number
Source:
Returns:
sign -1, 0, 1
Type
number