ConvexHull.html 8.3 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 23
		<p>
		</p>
M
r85  
Mr.doob 已提交
24 25 26

		<h2>Properties</h2>

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

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

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

M
r104  
Mr.doob 已提交
42
		<h3>[property:Float tolerance]</h3>
M
r92  
Mr.doob 已提交
43
		<p>
M
r104  
Mr.doob 已提交
44
			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 已提交
45
		</p>
M
r85  
Mr.doob 已提交
46 47

		<h3>[property:VertexList unassigned]</h3>
M
r92  
Mr.doob 已提交
48
		<p>
M
r85  
Mr.doob 已提交
49
			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 已提交
50
		</p>
M
r85  
Mr.doob 已提交
51 52

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

		<h2>Methods</h2>

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

M
r104  
Mr.doob 已提交
63 64
		<p>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 已提交
65

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

M
r104  
Mr.doob 已提交
70
		<p>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 已提交
71

M
r105  
Mr.doob 已提交
72
		<h3>[method:ConvexHull addVertexToFace]( [param:VertexNode vertex], [param:Face face]	)</h3>
M
r93  
Mr.doob 已提交
73
		[page:VertexNodeNode vertex] - The vertex to add.<br /><br />
M
r85  
Mr.doob 已提交
74 75
		[page:Face face] - The target face.<br /><br />

M
r92  
Mr.doob 已提交
76
		<p>Adds a vertex to the 'assigned' list of vertices and assigns it to the given face.</p>
M
r85  
Mr.doob 已提交
77

M
r105  
Mr.doob 已提交
78
		<h3>[method:ConvexHull addVertexToHull]( [param:VertexNode eyeVertex] )</h3>
M
r104  
Mr.doob 已提交
79
		[page:VertexNode eyeVertex] - The vertex that is added to the hull.<br /><br />
M
r85  
Mr.doob 已提交
80

M
r104  
Mr.doob 已提交
81 82 83 84 85 86 87 88
		<p>Adds a vertex to the hull with the following algorithm
			<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 已提交
89

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

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

M
r105  
Mr.doob 已提交
94
		<h3>[method:ConvexHull compute]()</h3>
M
r104  
Mr.doob 已提交
95 96 97 98 99 100 101

		<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 已提交
102
		<h3>[method:ConvexHull computeHorizon]( [param:Vector3 eyePoint], [param:HalfEdge crossEdge], [param:Face face], [param:Array horizon]	)</h3>
M
r104  
Mr.doob 已提交
103 104 105 106 107 108 109
		[page:Vector3 eyePoint] - The 3D-coordinates of a point.<br /><br />
		[page:HalfEdge crossEdge] - The edge used to jump to the current face.<br /><br />
		[page:Face face] - The current face being tested.<br /><br />
		[page:Array horizon] - The edges that form part of the horizon in CCW order.<br /><br />

		<p>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
r105  
Mr.doob 已提交
110
		<h3>[method:ConvexHull computeInitialHull]()</h3>
M
r104  
Mr.doob 已提交
111 112 113

		<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 已提交
114
		<h3>[method:ConvexHull containsPoint]( [param:Vector3 point] )</h3>
M
r104  
Mr.doob 已提交
115 116 117
		[page:Vector3 point] - A point in 3D space.<br /><br />

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

M
r105  
Mr.doob 已提交
119
		<h3>[method:ConvexHull deleteFaceVertices]( [param:Face face], [param:Face absorbingFace]	)</h3>
M
r85  
Mr.doob 已提交
120 121 122
		[page:Face face] - The given face.<br /><br />
		[page:Face absorbingFace] - An optional face that tries to absorb the vertices of the first face.<br /><br />

M
r92  
Mr.doob 已提交
123
		<p>Removes all the visible vertices that 'face' is able to see.
M
r85  
Mr.doob 已提交
124 125 126 127 128
			<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 已提交
129
		</p>
M
r85  
Mr.doob 已提交
130

M
r104  
Mr.doob 已提交
131 132 133
		<h3>[method:Vector3 intersectRay]( [param:Ray ray], [param:Vector3 target] )</h3>
		[page:Ray ray] - The given ray.<br /><br />
		[page:Vector3 target] - The target vector representing the intersection point.<br /><br />
M
r85  
Mr.doob 已提交
134

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

M
r104  
Mr.doob 已提交
137 138
		<h3>[method:Boolean intersectsRay]( [param:Ray ray] )</h3>
		[page:Ray ray] - The given ray.<br /><br />
M
r85  
Mr.doob 已提交
139

M
r104  
Mr.doob 已提交
140
		<p>Returns *true* if the given ray intersects with this convex hull.</p>
M
r85  
Mr.doob 已提交
141

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

M
r104  
Mr.doob 已提交
144
		<p>Makes this convex hull empty.</p>
M
r85  
Mr.doob 已提交
145 146 147

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

M
r92  
Mr.doob 已提交
148
		<p>Finds the next vertex to create faces with the current hull.
M
r85  
Mr.doob 已提交
149 150 151 152 153
			<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 已提交
154
		</p>
M
r85  
Mr.doob 已提交
155

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

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

M
r104  
Mr.doob 已提交
160 161
		<h3>[method:VertexNode removeAllVerticesFromFace]( [param:Face face]	)</h3>
		[page:Face face] - The given face.<br /><br />
M
r85  
Mr.doob 已提交
162

M
r104  
Mr.doob 已提交
163
		<p>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 已提交
164

M
r105  
Mr.doob 已提交
165
		<h3>[method:ConvexHull removeVertexFromFace]( [param:VertexNode vertex], [param:Face face]	)</h3>
M
r104  
Mr.doob 已提交
166 167
		[page:VertexNode vertex] - The vertex to remove.<br /><br />
		[page:Face face] - The target face.<br /><br />
M
r85  
Mr.doob 已提交
168

M
r104  
Mr.doob 已提交
169
		<p>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 已提交
170

M
r105  
Mr.doob 已提交
171
		<h3>[method:ConvexHull resolveUnassignedPoints]( [param:Array newFaces]	)</h3>
M
r104  
Mr.doob 已提交
172
		[page:Face newFaces] - An array of new faces.<br /><br />
M
r85  
Mr.doob 已提交
173

M
r104  
Mr.doob 已提交
174
		<p>Reassigns as many vertices as possible from the unassigned list to the new faces.</p>
M
r85  
Mr.doob 已提交
175

M
r105  
Mr.doob 已提交
176
		<h3>[method:ConvexHull setFromObject]( [param:Object3D object] )</h3>
M
r104  
Mr.doob 已提交
177
		[page:Object3D object] - [page:Object3D] to compute the convex hull of.<br /><br />
M
r85  
Mr.doob 已提交
178

M
r104  
Mr.doob 已提交
179 180
		<p>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 已提交
181

M
r105  
Mr.doob 已提交
182
		<h3>[method:ConvexHull setFromPoints]( [param:Array points] )</h3>
M
r104  
Mr.doob 已提交
183
		[page:Array points] - Array of [page:Vector3 Vector3s] that the resulting convex hull will contain.<br /><br />
M
r85  
Mr.doob 已提交
184

M
r104  
Mr.doob 已提交
185
		<p>Computes to convex hull for the given array of points.</p>
M
r85  
Mr.doob 已提交
186 187 188

		<h2>Source</h2>

M
r108  
Mr.doob 已提交
189 190 191
		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/ConvexHull.js]
		</p>
M
r85  
Mr.doob 已提交
192 193
	</body>
</html>