Home Reference Source
public class | source

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

hasValue(array: *, value: *): boolean

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:

NameTypeAttributeDescription
start *
end *

Return:

*

The angle.

public static angle2pi(start: *, end: *): * source

shifts angle to be 0 to 2pi

Params:

NameTypeAttributeDescription
start *
end *

Return:

*

public static closestPointOnLine(point: *, start: *, end: *): * source

Gets the projection of a point onto a line.

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
arr *
shift *

Return:

*

public static distance(start: *, end: *): * source

Gets the distance of two points.

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
array *
action *

public static forEachIndexed(array: *, action: *) source

Params:

NameTypeAttributeDescription
array *
action *

public static guide(): * source

Creates a Guide.

Return:

*

A new Guide.

public static hasValue(array: *, value: *): boolean source

Checks if value is in array

Params:

NameTypeAttributeDescription
array *
value *

Return:

boolean

public static isClockwise(points: *): * source

Checks if an array of points is clockwise.

Params:

NameTypeAttributeDescription
points *

Is array of points with x,y attributes

Return:

*

True if clockwise.

public static lineLineIntersect(lineAStart: *, lineAEnd: *, lineBStart: *, lineBEnd: *): * source

Params:

NameTypeAttributeDescription
lineAStart *
lineAEnd *
lineBStart *
lineBEnd *

Return:

*

public static lineLineIntersectPoint(aStart: *, aEnd: *, bStart: *, bEnd: *): * source

Params:

NameTypeAttributeDescription
aStart *
aEnd *
bStart *
bEnd *

Return:

*

public static linePolygonIntersect(point: *, point2: *, corners: *): boolean source

Corners is an array of points with x,y attributes

Params:

NameTypeAttributeDescription
point *
point2 *
corners *

Return:

boolean

public static map(array: *, func: *): * source

Params:

NameTypeAttributeDescription
array *
func *

Return:

*

public static pointDistanceFromLine(point: *, start: *, end: *): * source

Determines the distance of a point from a line.

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
insideCorners *
outsideCorners *
start *

Return:

boolean

public static polygonOutsidePolygon(insideCorners: *, outsideCorners: *, start: *): boolean source

Checks if any corners of firstCorners is inside the polygon described by secondCorners

Params:

NameTypeAttributeDescription
insideCorners *
outsideCorners *
start *

Return:

boolean

public static polygonPolygonIntersect(firstCorners: *, secondCorners: *): boolean source

both arguments are arrays of corners with x,y attributes

Params:

NameTypeAttributeDescription
firstCorners *
secondCorners *

Return:

boolean

public static removeIf(array: *, func: *): * source

Remove elements in array if func(element) returns true

Params:

NameTypeAttributeDescription
array *
func *

Return:

*

public static removeValue(array: *, value: *) source

Remove value from array, if it is present

Params:

NameTypeAttributeDescription
array *
value *

public static subtract(array: *, subArray: *): * source

Subtracts the elements in subArray from array

Params:

NameTypeAttributeDescription
array *
subArray *

Return:

*

public static unique(arr: *, hashFunc: *): * source

Returns in the unique elemnts in arr

Params:

NameTypeAttributeDescription
arr *
hashFunc *

Return:

*