Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QuickHull

Hierarchy

  • QuickHull

Index

Constructors

Properties

claimed: VertexList
discardedFaces: Face[]
faces: Face[]
nFaces: number
nPoints: number
newFaces: Face[]
tolerance: number
unclaimed: VertexList
vertexPointIndices: number[]
vertices: Vertex[]

Methods

  • Creates a face with the points eyeVertex.point, horizonEdge.tail and horizonEdge.tail in ccw order

    Parameters

    Returns null | HalfEdge

    The half edge whose vertex is the eyeVertex

  • Adds horizon.length faces to the hull, each face will be 'linked' with the horizon opposite face and the face on the left/right

    Parameters

    • eyeVertex: Vertex
    • horizon: HalfEdge[]

      A chain of half edges in ccw order

    Returns void

  • addVertexToHull(eyeVertex: Vertex): void
  • Adds a vertex to the hull with the following algorithm

    • Compute the horizon which is a chain of half edges, for an edge to belong to this group it must be the edge connecting a face that can see eyeVertex and a face which cannot see eyeVertex
    • All the faces that can see eyeVertex have its visible vertices removed from the claimed VertexList
    • A new set of faces is created with each edge of the horizon and eyeVertex, each face is connected with the opposite horizon face and the face on the left/right
    • The new faces are merged if possible with the opposite horizon face first and then the faces on the right/left
    • The vertices removed from all the visible faces are assigned to the new faces if possible

    Parameters

    Returns void

  • build(): void
  • collectFaces(skipTriangulation: boolean): (undefined | number)[][]
  • Parameters

    • skipTriangulation: boolean

    Returns (undefined | number)[][]

  • Computes the extremes of a tetrahedron which will be the initial hull

    Returns Vertex[][]

    The min/max vertices in the x,y,z directions

  • Computes a chain of half edges in ccw order called the horizon, for an edge to be part of the horizon it must join a face that can see eyePoint and a face that cannot see eyePoint

    Parameters

    • eyePoint: number[]

      The coordinates of a point

    • crossEdge: HalfEdge

      The edge used to jump to the current face

    • face: Face

      The current face being tested

    • horizon: HalfEdge[]

      The edges that form part of the horizon in ccw order

    Returns void

  • createInitialSimplex(): void
  • Compues the initial tetrahedron assigning to its faces all the points that are candidates to form part of the hull

    Returns void

  • deleteFaceVertices(face: Face, absorbingFace: Face): void
  • Removes all the visible vertices that face is able to see, additionally checking the following:

    If absorbingFace doesn't exist then all the removed vertices will be added to the unclaimed vertex list

    If absorbingFace exists then this method will assign all the vertices of face that can see absorbingFace, if a vertex cannot see absorbingFace it's added to the unclaimed vertex list

    Parameters

    Returns void

  • doAdjacentMerge(face: Face, mergeType: number): boolean
  • Merges a face with none/any/all its neighbors according to the strategy used

    if mergeType is MERGE_NON_CONVEX_WRT_LARGER_FACE then the merge will be decided based on the face with the larger area, the centroid of the face with the smaller area will be checked against the one with the larger area to see if it's in the merge range [tolerance, -tolerance] i.e.

    dot(centroid smaller face, larger face normal) - larger face offset > -tolerance

    Note that the first check (with +tolerance) was done on computeHorizon

    If the above is not true then the check is done with respect to the smaller face i.e.

    dot(centroid larger face, smaller face normal) - smaller face offset > -tolerance

    If true then it means that two faces are non convex (concave), even if the dot(...) - offset value is > 0 (that's the point of doing the merge in the first place)

    If two faces are concave then the check must also be done on the other face but this is done in another merge pass, for this to happen the face is marked in a temporal NON_CONVEX state

    if mergeType is MERGE_NON_CONVEX then two faces will be merged only if they pass the following conditions

    dot(centroid smaller face, larger face normal) - larger face offset > -tolerance dot(centroid larger face, smaller face normal) - smaller face offset > -tolerance

    Parameters

    • face: Face
    • mergeType: number

    Returns boolean

  • nextVertexToAdd(): undefined | Vertex
  • Finds the next vertex to make faces with the current hull

    • let face be the first face existing in the claimed vertex list
    • if face doesn't exist then return since there're no vertices left
    • otherwise for each vertex that face sees find the one furthest away from face

    Returns undefined | Vertex

    Returns undefined when there're no more visible vertices

  • oppositeFaceDistance(edge: HalfEdge): undefined | number
  • Computes the distance from edge opposite face's centroid to edge.face

    Parameters

    Returns undefined | number

    • A positive number when the centroid of the opposite face is above the face i.e. when the faces are concave
    • A negative number when the centroid of the opposite face is below the face i.e. when the faces are convex
  • reindexFaceAndVertices(): void
  • removeAllVerticesFromFace(face: Face): undefined | Vertex
  • Removes all the visible vertices that face is able to see which are stored in the claimed vertext list

    Parameters

    Returns undefined | Vertex

    If face had visible vertices returns face.outside, otherwise undefined

  • removeVertexFromFace(vertex: Vertex, face: Face): void
  • Removes vertex for the claimed list of vertices, it also makes sure that the link from face to the first vertex it sees in claimed is linked correctly after the removal

    Parameters

    Returns void

  • resolveUnclaimedPoints(newFaces: Face[]): void
  • Reassigns as many vertices as possible from the unclaimed list to the new faces

    Parameters

    Returns void

  • createHull(_points: (number[] | Vector3)[]): (undefined | number)[][]
  • Creates a new array of faces from an array of points.

    Parameters

    • _points: (number[] | Vector3)[]

      The array of points to create the hull from.

    Returns (undefined | number)[][]

    An array of faces.