Utils
Static Method Summary
Static Public Methods | ||
public static |
angle(start: *, end: *): * Gets the angle between point1 -> start and 0,0 -> point2 (-pi to pi) |
|
public static |
angle2pi(start: *, end: *): * shifts angle to be 0 to 2pi |
|
public static |
closestPointOnLine(point: *, start: *, end: *): * Gets the projection of a point onto a line. |
|
public static |
cycle(arr: *, shift: *): * Shift the items in an array by shift (positive integer) |
|
public static |
distance(start: *, end: *): * Gets the distance of two points. |
|
public static |
forEach(array: *, action: *) |
|
public static |
forEachIndexed(array: *, action: *) |
|
public static |
guide(): * Creates a Guide. |
|
public static |
Checks if value is in array |
|
public static |
isClockwise(points: *): * Checks if an array of points is clockwise. |
|
public static |
lineLineIntersect(lineAStart: *, lineAEnd: *, lineBStart: *, lineBEnd: *): * |
|
public static |
lineLineIntersectPoint(aStart: *, aEnd: *, bStart: *, bEnd: *): * |
|
public static |
linePolygonIntersect(point: *, point2: *, corners: *): boolean Corners is an array of points with x,y attributes |
|
public static |
map(array: *, func: *): * |
|
public static |
pointDistanceFromLine(point: *, start: *, end: *): * Determines the distance of a point from a line. |
|
public static |
pointInPolygon(corners: *, startX: *, startY: *): * |
|
public static |
pointInPolygon2(corners: *, startX: *, startY: *): * |
|
public static |
polygonInsidePolygon(insideCorners: *, outsideCorners: *, start: *): boolean Checks if all corners of insideCorners are inside the polygon described by outsideCorners |
|
public static |
polygonOutsidePolygon(insideCorners: *, outsideCorners: *, start: *): boolean Checks if any corners of firstCorners is inside the polygon described by secondCorners |
|
public static |
polygonPolygonIntersect(firstCorners: *, secondCorners: *): boolean both arguments are arrays of corners with x,y attributes |
|
public static |
removeIf(array: *, func: *): * Remove elements in array if func(element) returns true |
|
public static |
removeValue(array: *, value: *) Remove value from array, if it is present |
|
public static |
subtract(array: *, subArray: *): * Subtracts the elements in subArray from array |
|
public static |
unique(arr: *, hashFunc: *): * Returns in the unique elemnts in arr |
Static Public Methods
public static angle(start: *, end: *): * source
Gets the angle between point1 -> start and 0,0 -> point2 (-pi to pi)
Params:
Name | Type | Attribute | Description |
start | * | ||
end | * |
Return:
* | The angle. |
public static angle2pi(start: *, end: *): * source
shifts angle to be 0 to 2pi
Params:
Name | Type | Attribute | Description |
start | * | ||
end | * |
Return:
* |
public static closestPointOnLine(point: *, start: *, end: *): * source
Gets the projection of a point onto a line.
Params:
Name | Type | Attribute | Description |
point | * | the point |
|
start | * | the starting coordinates of the line as THREE.Vector2 |
|
end | * | the ending coordinates of the line as THREE.Vector2 |
Return:
* | The point as THREE.Vector2. |
public static cycle(arr: *, shift: *): * source
Shift the items in an array by shift (positive integer)
Params:
Name | Type | Attribute | Description |
arr | * | ||
shift | * |
Return:
* |
public static distance(start: *, end: *): * source
Gets the distance of two points.
Params:
Name | Type | Attribute | Description |
start | * | the starting coordinate of the line as Vector2 |
|
end | * | the ending coordinate of the line as Vector2 |
Return:
* | The distance. |
public static forEach(array: *, action: *) source
Params:
Name | Type | Attribute | Description |
array | * | ||
action | * |
public static forEachIndexed(array: *, action: *) source
Params:
Name | Type | Attribute | Description |
array | * | ||
action | * |
public static hasValue(array: *, value: *): boolean source
Checks if value is in array
Params:
Name | Type | Attribute | Description |
array | * | ||
value | * |
public static isClockwise(points: *): * source
Checks if an array of points is clockwise.
Params:
Name | Type | Attribute | Description |
points | * | Is array of points with x,y attributes |
Return:
* | True if clockwise. |
public static lineLineIntersect(lineAStart: *, lineAEnd: *, lineBStart: *, lineBEnd: *): * source
Params:
Name | Type | Attribute | Description |
lineAStart | * | ||
lineAEnd | * | ||
lineBStart | * | ||
lineBEnd | * |
Return:
* |
public static lineLineIntersectPoint(aStart: *, aEnd: *, bStart: *, bEnd: *): * source
Params:
Name | Type | Attribute | Description |
aStart | * | ||
aEnd | * | ||
bStart | * | ||
bEnd | * |
Return:
* |
public static linePolygonIntersect(point: *, point2: *, corners: *): boolean source
Corners is an array of points with x,y attributes
Params:
Name | Type | Attribute | Description |
point | * | ||
point2 | * | ||
corners | * |
public static map(array: *, func: *): * source
Params:
Name | Type | Attribute | Description |
array | * | ||
func | * |
Return:
* |
public static pointDistanceFromLine(point: *, start: *, end: *): * source
Determines the distance of a point from a line.
Params:
Name | Type | Attribute | Description |
point | * | The Point coordinates as THREE.Vector2 |
|
start | * | The starting coordinates of the line as THREE.Vector2 |
|
end | * | The ending coordinates of the line as THREE.Vector2 |
Return:
* | The distance value (number). |
public static pointInPolygon(corners: *, startX: *, startY: *): * source
Params:
Name | Type | Attribute | Description |
corners | * | Is an array of points with x,y attributes |
|
startX | * | X start coord for raycast |
|
startY | * | Y start coord for raycast |
Return:
* |
public static pointInPolygon2(corners: *, startX: *, startY: *): * source
Params:
Name | Type | Attribute | Description |
corners | * | Is an array of points with x,y attributes |
|
startX | * | X start coord for raycast |
|
startY | * | Y start coord for raycast |
Return:
* |
public static polygonInsidePolygon(insideCorners: *, outsideCorners: *, start: *): boolean source
Checks if all corners of insideCorners are inside the polygon described by outsideCorners
Params:
Name | Type | Attribute | Description |
insideCorners | * | ||
outsideCorners | * | ||
start | * |
public static polygonOutsidePolygon(insideCorners: *, outsideCorners: *, start: *): boolean source
Checks if any corners of firstCorners is inside the polygon described by secondCorners
Params:
Name | Type | Attribute | Description |
insideCorners | * | ||
outsideCorners | * | ||
start | * |
public static polygonPolygonIntersect(firstCorners: *, secondCorners: *): boolean source
both arguments are arrays of corners with x,y attributes
Params:
Name | Type | Attribute | Description |
firstCorners | * | ||
secondCorners | * |
public static removeIf(array: *, func: *): * source
Remove elements in array if func(element) returns true
Params:
Name | Type | Attribute | Description |
array | * | ||
func | * |
Return:
* |
public static removeValue(array: *, value: *) source
Remove value from array, if it is present
Params:
Name | Type | Attribute | Description |
array | * | ||
value | * |
public static subtract(array: *, subArray: *): * source
Subtracts the elements in subArray from array
Params:
Name | Type | Attribute | Description |
array | * | ||
subArray | * |
Return:
* |
public static unique(arr: *, hashFunc: *): * source
Returns in the unique elemnts in arr
Params:
Name | Type | Attribute | Description |
arr | * | ||
hashFunc | * |
Return:
* |