ConvexHull.html 8.4 KB
Newer Older
M
r85  
Mr.doob 已提交
1 2 3 4
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
M
r106  
Mr.doob 已提交
5
		<base href="../../../../" />
M
r85  
Mr.doob 已提交
6 7 8 9 10 11 12
		<script src="list.js"></script>
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
	</head>
	<body>
		<h1>[name]</h1>

M
r92  
Mr.doob 已提交
13
		<p class="desc">
M
r105  
Mr.doob 已提交
14
			A convex hull class. Implements the Quickhull algorithm by: Dirk Gregorius. March 2014, Game Developers Conference: [link:http://media.steampowered.com/apps/valve/2014/DirkGregorius_ImplementingQuickHull.pdf Implementing QuickHull].
M
r92  
Mr.doob 已提交
15
		</p>
M
r85  
Mr.doob 已提交
16 17 18 19 20 21


		<h2>Constructor</h2>


		<h3>[name]()</h3>
M
r92  
Mr.doob 已提交
22
		<p>
M
r115  
Mr.doob 已提交
23
			Creates a new instance of [name].
M
r92  
Mr.doob 已提交
24
		</p>
M
r85  
Mr.doob 已提交
25 26 27

		<h2>Properties</h2>

M
r104  
Mr.doob 已提交
28
		<h3>[property:VertexList assigned]</h3>
M
r92  
Mr.doob 已提交
29
		<p>
M
r104  
Mr.doob 已提交
30
			This [page:VertexList vertex list] holds all vertices that are assigned to a face. Default is an empty vertex list.
M
r92  
Mr.doob 已提交
31
		</p>
M
r85  
Mr.doob 已提交
32 33

		<h3>[property:Array faces]</h3>
M
r92  
Mr.doob 已提交
34
		<p>
M
r85  
Mr.doob 已提交
35
			The generated faces of the convex hull. Default is an empty array.
M
r92  
Mr.doob 已提交
36
		</p>
M
r85  
Mr.doob 已提交
37 38

		<h3>[property:Array newFaces]</h3>
M
r92  
Mr.doob 已提交
39
		<p>
M
r85  
Mr.doob 已提交
40
			This array holds the faces that are generated within a single iteration. Default is an empty array.
M
r92  
Mr.doob 已提交
41
		</p>
M
r85  
Mr.doob 已提交
42

M
r104  
Mr.doob 已提交
43
		<h3>[property:Float tolerance]</h3>
M
r92  
Mr.doob 已提交
44
		<p>
M
r104  
Mr.doob 已提交
45
			The epsilon value that is used for internal comparative operations. The calculation of this value depends on the size of the geometry. Default is -1.
M
r92  
Mr.doob 已提交
46
		</p>
M
r85  
Mr.doob 已提交
47 48

		<h3>[property:VertexList unassigned]</h3>
M
r92  
Mr.doob 已提交
49
		<p>
M
r85  
Mr.doob 已提交
50
			This [page:VertexList vertex list] holds all vertices that are not assigned to a face. Default is an empty vertex list.
M
r92  
Mr.doob 已提交
51
		</p>
M
r85  
Mr.doob 已提交
52 53

		<h3>[property:Array vertices]</h3>
M
r92  
Mr.doob 已提交
54
		<p>
M
r85  
Mr.doob 已提交
55
			The internal representation of the given geometry data (an array of [page:VertexNode vertices]).
M
r92  
Mr.doob 已提交
56
		</p>
M
r85  
Mr.doob 已提交
57 58 59

		<h2>Methods</h2>

M
r104  
Mr.doob 已提交
60
		<h3>[method:HalfEdge addAdjoiningFace]( [param:VertexNode eyeVertex], [param:HalfEdge horizonEdge] )</h3>
M
r115  
Mr.doob 已提交
61 62 63
		<p>
			[page:VertexNode eyeVertex] - The vertex that is added to the hull.<br />
			[page:HalfEdge horizonEdge] - A single edge of the horizon.<br /><br />
M
r85  
Mr.doob 已提交
64

M
r115  
Mr.doob 已提交
65 66 67
			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
		</p>
M
r85  
Mr.doob 已提交
68

M
r105  
Mr.doob 已提交
69
		<h3>[method:ConvexHull addNewFaces]( [param:VertexNode eyeVertex], [param:HalfEdge horizonEdge] )</h3>
M
r115  
Mr.doob 已提交
70 71 72
		<p>
			[page:VertexNode eyeVertex] - The vertex that is added to the hull.<br />
			[page:HalfEdge horizon] - An array of half-edges that form the horizon.<br /><br />
M
r85  
Mr.doob 已提交
73

M
r115  
Mr.doob 已提交
74 75
			Adds 'horizon.length' faces to the hull, each face will be linked with the horizon opposite face and the face on the left/right.
		</p>
M
r85  
Mr.doob 已提交
76

M
r105  
Mr.doob 已提交
77
		<h3>[method:ConvexHull addVertexToFace]( [param:VertexNode vertex], [param:Face face]	)</h3>
M
r115  
Mr.doob 已提交
78 79 80
		<p>
			[page:VertexNodeNode vertex] - The vertex to add.<br />
			[page:Face face] - The target face.<br /><br />
M
r85  
Mr.doob 已提交
81

M
r115  
Mr.doob 已提交
82 83
			Adds a vertex to the 'assigned' list of vertices and assigns it to the given face.
		</p>
M
r85  
Mr.doob 已提交
84

M
r105  
Mr.doob 已提交
85
		<h3>[method:ConvexHull addVertexToHull]( [param:VertexNode eyeVertex] )</h3>
M
r115  
Mr.doob 已提交
86 87
		<p>
			[page:VertexNode eyeVertex] - The vertex that is added to the hull.<br /><br />
M
r85  
Mr.doob 已提交
88

M
r115  
Mr.doob 已提交
89
			Adds a vertex to the hull with the following algorithm
M
r104  
Mr.doob 已提交
90 91 92 93 94 95 96
			<ul>
				<li>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'.</li>
				<li>All the faces that can see 'eyeVertex' have its visible vertices removed from the assigned vertex list.</li>
				<li>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.</li>
				<li>The vertices removed from all the visible faces are assigned to the new faces if possible.</li>
			</ul>
		</p>
M
r85  
Mr.doob 已提交
97

M
r105  
Mr.doob 已提交
98
		<h3>[method:ConvexHull cleanup]()</h3>
M
r85  
Mr.doob 已提交
99

M
r104  
Mr.doob 已提交
100 101
		<p>Cleans up internal properties after computing the convex hull.</p>

M
r105  
Mr.doob 已提交
102
		<h3>[method:ConvexHull compute]()</h3>
M
r104  
Mr.doob 已提交
103 104 105 106 107 108 109

		<p>Starts the execution of the quick hull algorithm.</p>

		<h3>[method:Object computeExtremes]()</h3>

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

M
r105  
Mr.doob 已提交
110
		<h3>[method:ConvexHull computeHorizon]( [param:Vector3 eyePoint], [param:HalfEdge crossEdge], [param:Face face], [param:Array horizon]	)</h3>
M
r115  
Mr.doob 已提交
111 112 113 114 115
		<p>
			[page:Vector3 eyePoint] - The 3D-coordinates of a point.<br />
			[page:HalfEdge crossEdge] - The edge used to jump to the current face.<br />
			[page:Face face] - The current face being tested.<br />
			[page:Array horizon] - The edges that form part of the horizon in CCW order.<br /><br />
M
r104  
Mr.doob 已提交
116

M
r115  
Mr.doob 已提交
117 118
			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'.
		</p>
M
r104  
Mr.doob 已提交
119

M
r105  
Mr.doob 已提交
120
		<h3>[method:ConvexHull computeInitialHull]()</h3>
M
r104  
Mr.doob 已提交
121 122 123

		<p>Computes the initial simplex assigning to its faces all the points that are candidates to form part of the hull.</p>

M
r105  
Mr.doob 已提交
124
		<h3>[method:ConvexHull containsPoint]( [param:Vector3 point] )</h3>
M
r115  
Mr.doob 已提交
125 126
		<p>
			[page:Vector3 point] - A point in 3D space.<br /><br />
M
r104  
Mr.doob 已提交
127

M
r115  
Mr.doob 已提交
128 129
			Returns *true* if the given point is inside this convex hull.
		</p>
M
r85  
Mr.doob 已提交
130

M
r105  
Mr.doob 已提交
131
		<h3>[method:ConvexHull deleteFaceVertices]( [param:Face face], [param:Face absorbingFace]	)</h3>
M
r115  
Mr.doob 已提交
132 133 134
		<p>
			[page:Face face] - The given face.<br />
			[page:Face absorbingFace] - An optional face that tries to absorb the vertices of the first face.<br /><br />
M
r85  
Mr.doob 已提交
135

M
r115  
Mr.doob 已提交
136
			Removes all the visible vertices that 'face' is able to see.
M
r85  
Mr.doob 已提交
137 138 139 140 141
			<ul>
				<li>If 'absorbingFace' doesn't exist, then all the removed vertices will be added to the 'unassigned' vertex list.</li>
				<li>If 'absorbingFace' exists, then this method will assign all the vertices of 'face' that can see 'absorbingFace'.</li>
				<li>If a vertex cannot see 'absorbingFace', it's added to the 'unassigned' vertex list.</li>
			</ul>
M
r92  
Mr.doob 已提交
142
		</p>
M
r85  
Mr.doob 已提交
143

M
r104  
Mr.doob 已提交
144
		<h3>[method:Vector3 intersectRay]( [param:Ray ray], [param:Vector3 target] )</h3>
M
r115  
Mr.doob 已提交
145 146 147
		<p>
			[page:Ray ray] - The given ray.<br />
			[page:Vector3 target] - The target vector representing the intersection point.<br /><br />
M
r85  
Mr.doob 已提交
148

M
r115  
Mr.doob 已提交
149 150
			Performs a ray intersection test with this convext hull. If no intersection is found, *null* is returned.
		</p>
M
r85  
Mr.doob 已提交
151

M
r104  
Mr.doob 已提交
152
		<h3>[method:Boolean intersectsRay]( [param:Ray ray] )</h3>
M
r115  
Mr.doob 已提交
153 154
		<p>
			[page:Ray ray] - The given ray.<br /><br />
M
r85  
Mr.doob 已提交
155

M
r115  
Mr.doob 已提交
156 157
			Returns *true* if the given ray intersects with this convex hull.
		</p>
M
r85  
Mr.doob 已提交
158

M
r105  
Mr.doob 已提交
159
		<h3>[method:ConvexHull makeEmpty]()</h3>
M
r85  
Mr.doob 已提交
160

M
r104  
Mr.doob 已提交
161
		<p>Makes this convex hull empty.</p>
M
r85  
Mr.doob 已提交
162 163 164

		<h3>[method:VertexNode nextVertexToAdd]()</h3>

M
r92  
Mr.doob 已提交
165
		<p>Finds the next vertex to create faces with the current hull.
M
r85  
Mr.doob 已提交
166 167 168 169 170
			<ul>
				<li>Let the initial face be the first face existing in the 'assigned' vertex list.</li>
				<li>If a face doesn't exist then return since there're no vertices left.</li>
				<li>Otherwise for each vertex that face sees find the one furthest away from it.</li>
			</ul>
M
r92  
Mr.doob 已提交
171
		</p>
M
r85  
Mr.doob 已提交
172

M
r105  
Mr.doob 已提交
173
		<h3>[method:ConvexHull reindexFaces]()</h3>
M
r85  
Mr.doob 已提交
174

M
r104  
Mr.doob 已提交
175
		<p>Removes inactive (e.g. deleted) faces from the internal face list.</p>
M
r85  
Mr.doob 已提交
176

M
r104  
Mr.doob 已提交
177
		<h3>[method:VertexNode removeAllVerticesFromFace]( [param:Face face]	)</h3>
M
r115  
Mr.doob 已提交
178 179
		<p>
			[page:Face face] - The given face.<br /><br />
M
r85  
Mr.doob 已提交
180

M
r115  
Mr.doob 已提交
181 182
			Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list.
		</p>
M
r85  
Mr.doob 已提交
183

M
r105  
Mr.doob 已提交
184
		<h3>[method:ConvexHull removeVertexFromFace]( [param:VertexNode vertex], [param:Face face]	)</h3>
M
r115  
Mr.doob 已提交
185 186 187
		<p>
			[page:VertexNode vertex] - The vertex to remove.<br />
			[page:Face face] - The target face.<br /><br />
M
r85  
Mr.doob 已提交
188

M
r115  
Mr.doob 已提交
189 190
			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.
		</p>
M
r85  
Mr.doob 已提交
191

M
r105  
Mr.doob 已提交
192
		<h3>[method:ConvexHull resolveUnassignedPoints]( [param:Array newFaces]	)</h3>
M
r115  
Mr.doob 已提交
193 194
		<p>
			[page:Face newFaces] - An array of new faces.<br /><br />
M
r85  
Mr.doob 已提交
195

M
r115  
Mr.doob 已提交
196 197
			Reassigns as many vertices as possible from the unassigned list to the new faces.
		</p>
M
r85  
Mr.doob 已提交
198

M
r105  
Mr.doob 已提交
199
		<h3>[method:ConvexHull setFromObject]( [param:Object3D object] )</h3>
M
r115  
Mr.doob 已提交
200 201
		<p>
			[page:Object3D object] - [page:Object3D] to compute the convex hull of.<br /><br />
M
r85  
Mr.doob 已提交
202

M
r115  
Mr.doob 已提交
203 204
			Computes the convex hull of an [page:Object3D] (including its children),accounting for the world transforms of both the object and its childrens.
		</p>
M
r85  
Mr.doob 已提交
205

M
r105  
Mr.doob 已提交
206
		<h3>[method:ConvexHull setFromPoints]( [param:Array points] )</h3>
M
r115  
Mr.doob 已提交
207 208
		<p>
			[page:Array points] - Array of [page:Vector3 Vector3s] that the resulting convex hull will contain.<br /><br />
M
r85  
Mr.doob 已提交
209

M
r115  
Mr.doob 已提交
210 211
			Computes to convex hull for the given array of points.
		</p>
M
r85  
Mr.doob 已提交
212 213 214

		<h2>Source</h2>

M
r108  
Mr.doob 已提交
215
		<p>
M
r114  
Mr.doob 已提交
216
			[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/ConvexHull.js]
M
r108  
Mr.doob 已提交
217
		</p>
M
r85  
Mr.doob 已提交
218 219
	</body>
</html>