BGE/QuickHull
Alias: BGE.QuickHull
Static Methods
getTrianglesFromPoints(
pointsArray?: Array.<BGE.Math.Vector>,
hull?: boolean,
): Array.<Array.<BGE.Math.Vector>>
Gets a series of triangles for the convex space defined by an array of {x,y} points
Parameters
pointsArray(Array.<BGE.Math.Vector>, optional, default: "[]") — array of {x,y} objectshull(boolean, optional, default: true) — perform a quick hull operation
Returns
Array.<Array.<BGE.Math.Vector>>— array of triangles, each is array of 3 {x,y} points
QuickHull(
pointsArray?: Array.<BGE.Math.Vector>,
): Array.<BGE.Math.Vector>
Implementation of the QuickHull algorithm for finding convex hull of a set of points Modified from: https://github.com/claytongulick/quickhull Original author Clay Gulick
Parameters
pointsArray(Array.<BGE.Math.Vector>, optional, default: "[]") — array of {x,y} objects
Returns
Array.<BGE.Math.Vector>— the minimal set of points for a convex hull
getMinMaxPoints(
pointsArray?: Array.<BGE.Math.Vector>,
vertical?: boolean,
): Array.<BGE.Math.Vector>
Gets the min and max points in the set along the X axis modified from https:'github.com/claytongulick/quickhull
Parameters
pointsArray(Array.<BGE.Math.Vector>, optional, default: "[]") — An array of {x,y} objectsvertical(boolean, optional, default: false)
Returns
Array.<BGE.Math.Vector>— array [ {x,y}, {x,y} ]
getMaxWidthAndHorizontalOffset(
pointsArray?: Array.<BGE.Math.Vector>,
)
Gets the total width from first point to last point horizontally, and the offset of the first point
Parameters
pointsArray(Array.<BGE.Math.Vector>, optional, default: "[]") — array of {x,y} objects
Returns
getMaxHeightAndVerticalOffset(
pointsArray?: Array.<BGE.Math.Vector>,
)
Gets the total height from first point to last point vertically, and the offset of the first point
Parameters
pointsArray(Array.<BGE.Math.Vector>, optional, default: "[]") — array of {x,y} objects
Returns
- object with {height as float, offset as float}
distanceFromLine(
point: BGE.Math.Vector,
line: Array.<BGE.Math.Vector>,
): float
Calculates the distance of a point from a line modified from https:'github.com/claytongulick/quickhull
Parameters
point(BGE.Math.Vector) — Array [x,y]line(Array.<BGE.Math.Vector>) — Array of two points [ [x1,y1], [x2,y2] ] return {float}
Returns
float
distalPoints(
line: Array.<BGE.Math.Vector>,
points: Array.<BGE.Math.Vector>,
)
Determines the set of points that lay outside the line (positive), and the most distal point Returns: {points: [ [x1, y1], ... ], max: [x,y] ]
Parameters
line(Array.<BGE.Math.Vector>)points(Array.<BGE.Math.Vector>)
Returns
addSegments(
hull: Array.<BGE.Math.Vector>,
line: Array.<BGE.Math.Vector>,
points: Array.<BGE.Math.Vector>,
): void
Recursively adds hull segments
Parameters
hull(Array.<BGE.Math.Vector>)line(Array.<BGE.Math.Vector>)points(Array.<BGE.Math.Vector>)
Returns
void