Utils
- Source:
Methods
(inner) circumcenter(a, b, c) → {Array}
- Source:
triangle circumcenter
Parameters:
Name | Type | Description |
---|---|---|
a |
Number | |
b |
Number | |
c |
Number |
Returns:
- Type
- Array
(inner) clamp(Number}, Number}, Number}) → {Number}
- Source:
Limit the range of a number
Parameters:
Name | Type | Description |
---|---|---|
Number} |
n the number |
|
Number} |
min minimum |
|
Number} |
max maximum |
Returns:
the clamped number
- Type
- Number
(inner) fi_lerp(a, b, p, dt, targetFPS) → {Number}
- Source:
Framerate independent linear interpolation
Parameters:
Name | Type | Default | Description |
---|---|---|---|
a |
Number | from |
|
b |
Number | to |
|
p |
Number | value between 0 and 1 |
|
dt |
Number | delta time in ms since last frame |
|
targetFPS |
Number |
60
|
target (context) fps |
Returns:
- Type
- Number
(inner) fixed(n, digits) → {Number}
- Source:
Limit the number to a given number of digits
Parameters:
Name | Type | Description |
---|---|---|
n |
Number | |
digits |
Number |
Returns:
- Type
- Number
(inner) isVector(v) → {Boolean}
- Source:
Check if the given Object can be used as a vector, this simply checks if the object has a x and y property
Parameters:
Name | Type | Description |
---|---|---|
v |
Object | Vector |
Returns:
- Type
- Boolean
(inner) lerp(a, b, p) → {Number}
- Source:
Linear interpolation between to values
Parameters:
Name | Type | Description |
---|---|---|
a |
Number | from |
b |
Number | to |
p |
Number | value between 0 and 1 |
Returns:
- Type
- Number
(inner) lineIntersection(x1, y1, x2, y2, x3, y3, x4, y4) → {Boolean|Object}
- Source:
Get the point where the two lines intersect
Parameters:
Name | Type | Description |
---|---|---|
x1 |
Number | start x coordinate of line 1 |
y1 |
Number | start y coordinate of line 1 |
x2 |
Number | end x coordinate of line 1 |
y2 |
Number | end y coordinate of line 1 |
x3 |
Number | start x coordinate of line 2 |
y3 |
Number | start y coordinate of line 2 |
x4 |
Number | end x coordinate of line 2 |
y4 |
Number | end y coordinate of line 2 |
Returns:
-
false if there is no intersection
- Type
- Boolean
-
object with x and y if there is an intersection
- Type
- Object
(inner) lineIntersectsLine(x1, y1, x2, y2, x3, y3, x4, y4) → {Boolean}
- Source:
Check if the two lines intersect
Parameters:
Name | Type | Description |
---|---|---|
x1 |
Number | start x coordinate of line 1 |
y1 |
Number | start y coordinate of line 1 |
x2 |
Number | end x coordinate of line 1 |
y2 |
Number | end y coordinate of line 1 |
x3 |
Number | start x coordinate of line 2 |
y3 |
Number | start y coordinate of line 2 |
x4 |
Number | end x coordinate of line 2 |
y4 |
Number | end y coordinate of line 2 |
Returns:
- Type
- Boolean
(inner) point(p) → {Array}
- Source:
convert the given variable to a point in array form, this is used in some internal math functions
Example
point(new Vector(1,2)) => [1,2]
point({x:1, y:2}) => [1,2]
point([1,2]) => [1,2]
Parameters:
Name | Type | Description |
---|---|---|
p |
Vector | Object | Array | a point as object, vector or array |
Returns:
Array with two entries [x, y]
never a reference to the original point
- Type
- Array
(inner) quadrant(x, y) → {Number}
- Source:
get the quadrant of the position
1 = positive x, positive y
2 = negative x, positive y
3 = negative x, negative y
4 = positive x, negative y
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | |
y |
Number |
Returns:
the quadrant
- Type
- Number