BGE/QuickHull

Alias: BGE.QuickHull


Static Methods

getTrianglesFromPoints( pointsArray?: dynamic, hull?: boolean, ): dynamic

static

Gets a series of triangles for the convex space defined by an array of {x,y} points

Parameters

  • pointsArray (dynamic, optional, default: "[]") — array of {x,y} objects
  • hull (boolean, optional, default: true) — perform a quick hull operation

Returns

  • dynamic — array of triangles, each is array of 3 {x,y} points

QuickHull(pointsArray?: dynamic): dynamic

static

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 (dynamic, optional, default: "[]") — array of {x,y} objects

Returns

  • dynamic — the minimal set of points for a convex hull

getMinMaxPoints( pointsArray?: Array.<BGE.Math.Vector>, vertical?: boolean, ): dynamic

static

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} objects
  • vertical (boolean, optional, default: false)

Returns

  • dynamic — array [ {x,y}, {x,y} ]

getMaxWidthAndHorizontalOffset( pointsArray?: Array.<BGE.Math.Vector>, ): dynamic

static

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

  • dynamic

getMaxHeightAndVerticalOffset(pointsArray?: dynamic): dynamic

static

Gets the total height from first point to last point vertically, and the offset of the first point

Parameters

  • pointsArray (dynamic, optional, default: "[]") — array of {x,y} objects

Returns

  • dynamic — object with {height as float, offset as float}

distanceFromLine( point: BGE.Math.Vector, line: Array.<BGE.Math.Vector>, ): float

static

Calculates the distance of a point from a line modified from https:'github.com/claytongulick/quickhull return {float}

Parameters

  • point (BGE.Math.Vector) — Array [x,y]
  • line (Array.<BGE.Math.Vector>) — Array of two points [ [x1,y1], [x2,y2] ]

Returns

  • float

distalPoints(line: dynamic, points: dynamic): dynamic

static

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 (dynamic)
  • points (dynamic)

Returns

  • dynamic

addSegments(hull: dynamic, line: dynamic, points: dynamic): void

static

Recursively adds hull segments

Parameters

  • hull (dynamic)
  • line (dynamic)
  • points (dynamic)

Returns

  • void