diff --git a/docs/api/math/convexhull/QuickHull3.html b/docs/api/math/convexhull/QuickHull3.html index de12e69133442727c0a2ed7223a336edfcd1f3a7..20831277b985cc2cfaf0068661ae29f4ca218831 100644 --- a/docs/api/math/convexhull/QuickHull3.html +++ b/docs/api/math/convexhull/QuickHull3.html @@ -11,7 +11,7 @@

[name]

- QuickHull3 infos + General information about the Quickhull algorithm: Dirk Gregorius. March 2014, Game Developers Conference: [link:http://media.steampowered.com/apps/valve/2014/DirkGregorius_ImplementingQuickHull.pdf Implementing QuickHull].
@@ -71,6 +71,103 @@
Makes this convex hull empty.
+

[method:QuickHull3 addVertexToFace]( [page:Vertex vertex], [page:Face face] )

+ [page:Vertex vertex] - The vetex to add.

+ [page:Face face] - The target face.

+ +
Adds a vertex to the 'assigned' list of vertices and assigns it to the given face.
+ +

[method:QuickHull3 removeVertexFromFace]( [page:Vertex vertex], [page:Face face] )

+ [page:Vertex vertex] - The vetex to remove.

+ [page:Face face] - The target face.

+ +
Removes a vertex from the 'assigned' list of vertices and from the given face. It also makes sure that the link from 'face' to the first vertex it sees in 'assigned' is linked correctly after the removal.
+ +

[method:Vertex removeAllVerticesFromFace]( [page:Face face] )

+ [page:Face face] - The given face.

+ +
Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list.
+ +

[method:QuickHull3 deleteFaceVertices]( [page:Face face], [page:Face absorbingFace] )

+ [page:Face face] - The given face.

+ [page:Face absorbingFace] - An optional face that tries to absorb the vertices of the first face.

+ +
Removes all the visible vertices that 'face' is able to see. + +
+ +

[method:QuickHull3 resolveUnassignedPoints]( [page:Array newFaces] )

+ [page:Face newFaces] - An array of new faces.

+ +
Reassigns as many vertices as possible from the unassigned list to the new faces.
+ +

[method:Object computeExtremes]()

+ +
Computes the extremes values (min/max vectors) which will be used to compute the inital hull.
+ +

[method:QuickHull3 computeInitialHull]()

+ +
Computes the initial simplex assigning to its faces all the points that are candidates to form part of the hull.
+ +

[method:QuickHull3 reindexFaces]()

+ +
Removes inactive (e.g. deleted) faces from the internal face list.
+ +

[method:Vertex nextVertexToAdd]()

+ +
Finds the next vertex to create faces with the current hull. + +
+ +

[method:QuickHull3 computeHorizon]( [page:Vector3 eyePoint], [page:HalfEdge crossEdge], [page:Face face], [page:Array horizon] )

+ [page:Vector3 eyePoint] - The 3D-coordinates of a point.

+ [page:HalfEdge crossEdge] - The edge used to jump to the current face.

+ [page:Face face] - The current face being tested.

+ [page:Array horizon] - The edges that form part of the horizon in CCW order.

+ +
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'.
+ +

[method:HalfEdge addAdjoiningFace]( [page:Vertex eyeVertex], [page:HalfEdge horizonEdge] )

+ [page:Vertex eyeVertex] - The vertex that is added to the hull.

+ [page:HalfEdge horizonEdge] - A single edge of the horizon.

+ +
Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order. + All the half edges are created in CCW order thus the face is always pointing outside the hull
+ +

[method:QuickHull3 addNewFaces]( [page:Vertex eyeVertex], [page:HalfEdge horizonEdge] )

+ [page:Vertex eyeVertex] - The vertex that is added to the hull.

+ [page:HalfEdge horizon] - An array of half-edges that form the horizon.

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

[method:QuickHull3 addVertexToHull]( [page:Vertex eyeVertex] )

+ [page:Vertex eyeVertex] - The vertex that is added to the hull.

+ +
Adds a vertex to the hull with the following algorithm + +
+ +

[method:QuickHull3 cleanup]()

+ +
Cleans up internal properties after computing the convex hull.
+ +

[method:QuickHull3 compute]()

+ +
Starts the execution of the quick hull algorithm.
+

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/src/math/convexhull/QuickHull3.js b/src/math/convexhull/QuickHull3.js index 35b2acefb680fefdbb676c019c25855ab05a423c..ae040a4efa2ba6044c5a428fb53647096aeeec0d 100644 --- a/src/math/convexhull/QuickHull3.js +++ b/src/math/convexhull/QuickHull3.js @@ -9,6 +9,8 @@ import { Visible, Deleted } from '../../constants'; /** * @author Mugen87 / https://github.com/Mugen87 * + * Ported from: https://github.com/maurizzzio/quickhull3d/ by Mauricio Poppe (https://github.com/maurizzzio) + * */ function QuickHull3() { @@ -18,6 +20,16 @@ function QuickHull3() { this.faces = []; // the generated faces of the convex hull this.newFaces = []; // this array holds the faces that are generated within a single iteration + // the vertex lists work as follows: + // + // let 'a' and 'b' be 'Face' instances + // let 'v' be points wrapped as instance of 'Vertex' + // + // [v, v, ..., v, v, v, ...] + // ^ ^ + // | | + // a.outside b.outside + // this.assigned = new VertexList(); this.unassigned = new VertexList(); @@ -119,7 +131,7 @@ Object.assign( QuickHull3.prototype, { }, - // Adds a 'vertex' to the 'assigned' list of vertices and assigns it to the given face. + // Adds a vertex to the 'assigned' list of vertices and assigns it to the given face addVertexToFace: function ( vertex, face ) { @@ -141,8 +153,7 @@ Object.assign( QuickHull3.prototype, { }, - // Removes 'vertex' for the 'assigned' list of vertices. - // It also makes sure that the link from 'face' to the first vertex it sees in 'assigned' is linked correctly after the removal + // Removes a vertex from the 'assigned' list of vertices and from the given face removeVertexFromFace: function ( vertex, face ) { @@ -168,9 +179,11 @@ Object.assign( QuickHull3.prototype, { this.assigned.remove( vertex ); + return this; + }, - // Removes all the visible vertices that 'face' is able to see which are stored in the 'assigned' vertext list + // Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list removeAllVerticesFromFace: function ( face ) { @@ -202,10 +215,6 @@ Object.assign( QuickHull3.prototype, { // Removes all the visible vertices that 'face' is able to see - // If 'absorbingFace' doesn't exist then all the removed vertices will be added to the 'unassigned' 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 'unassigned' vertex list. - deleteFaceVertices: function ( face, absorbingFace ) { var faceVertices = this.removeAllVerticesFromFace( face ); @@ -256,6 +265,8 @@ Object.assign( QuickHull3.prototype, { } + return this; + }, // Reassigns as many vertices as possible from the unassigned list to the new faces @@ -311,9 +322,11 @@ Object.assign( QuickHull3.prototype, { } + return this; + }, - // Computes the extremes of a tetrahedron which will be the initial hull + // Computes the extremes of a simplex which will be the initial hull computeExtremes: function () { @@ -582,6 +595,8 @@ Object.assign( QuickHull3.prototype, { } + return this; + }; }(), @@ -606,6 +621,8 @@ Object.assign( QuickHull3.prototype, { this.faces = activeFaces; + return this; + }, // Finds the next vertex to create faces with the current hull @@ -646,14 +663,9 @@ Object.assign( QuickHull3.prototype, { }, - // Computes a chain of half edges in ccw order called the 'horizon'. + // 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'. - // - // - eyePoint: The coordinates of a point - // - crossEdge: The edge used to jump to the current 'face' - // - face: The current face being tested - // - horizon: The edges that form part of the horizon in ccw order computeHorizon: function ( eyePoint, crossEdge, face, horizon ) { @@ -705,9 +717,11 @@ Object.assign( QuickHull3.prototype, { } while ( edge !== crossEdge ); + return this; + }, - // Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in ccw order + // Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order addAdjoiningFace: function ( eyeVertex, horizonEdge ) { @@ -765,6 +779,8 @@ Object.assign( QuickHull3.prototype, { firstSideEdge.next.setTwin( previousSideEdge ); + return this; + }, // Adds a vertex to the hull @@ -788,6 +804,8 @@ Object.assign( QuickHull3.prototype, { this.resolveUnassignedPoints( this.newFaces ); + return this; + }, cleanup: function () { @@ -796,6 +814,8 @@ Object.assign( QuickHull3.prototype, { this.unassigned.clear(); this.newFaces = []; + return this; + }, compute: function () { @@ -816,6 +836,8 @@ Object.assign( QuickHull3.prototype, { this.cleanup(); + return this; + } } );