Members
(static, constant) DegreesToRadians
(static, constant) E
(static, constant) HALFPI
(static, constant) MAX_NUMBER
(static, constant) MIN_NUMBER
(static, constant) PI
(static, constant) PI2
(static, constant) TAU
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 |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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 |
Returns:
[valA, valB]
- Type
- number
(static) randomRange()
random value min >= value >= max
(static) randomVariance(v) → {number}
Return a variance of +- v
Parameters:
| Name | Type | Description |
|---|---|---|
v |
number |
Returns:
[-v, v]
- Type
- number
(static) signOf(num) → {number}
Get the sign of a number
Parameters:
| Name | Type | Description |
|---|---|---|
num |
number |
Returns:
sign -1, 0, 1
- Type
- number