-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathH3DU.BezierCurve.html
executable file
·384 lines (276 loc) · 16.8 KB
/
H3DU.BezierCurve.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!DOCTYPE html><html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><title>H3DU.BezierCurve</title><meta name="viewport" content="width=device-width"><link rel=stylesheet type="text/css" href="/style.css"></head><body> <div class="header">
<p><a href="#navigation">Menu</a> - <a href="#top">Top</a> - <a href="/">Home</a> -
<a href="http://peteroupc.github.io/">Donate to Me</a></p></div>
<div class="mainarea" id="top">
<h1>H3DU.BezierCurve</h1>
<p><a href="index.html">Back to documentation index.</a></p>
<p><a name='H3DU.BezierCurve'></a></p>
<h3>H3DU.BezierCurve(cp, [u1], [u2])</h3>
<p><strong>Augments:</strong> <a href="H3DU.Curve.html">H3DU.Curve</a></p>
<p><b>Deprecated: Instead of this class, use <a href="H3DU.BSplineCurve.html#H3DU.BSplineCurve.fromBezierCurve">H3DU.BSplineCurve.fromBezierCurve</a>
to create a Bézier curve.</b></p>
<p>A <a href="H3DU.Curve.html">curve evaluator object</a> for a Bézier curve.</p>
<h4>Parameters</h4>
<ul>
<li><code>cp</code> (Type: Array.<Array.<number>>)<br>An array of control points as specified in <a href="H3DU.BSplineCurve.html#H3DU.BSplineCurve.fromBezierCurve">H3DU.BSplineCurve.fromBezierCurve</a>.</li>
<li><code>u1</code> (Type: number) (optional)<br>No longer used since version 2.0. The starting and ending points will be (0, 1). (This parameter was the starting point for the purpose of interpolation.)</li>
<li><code>u2</code> (Type: number) (optional)<br>No longer used since version 2.0. The starting and ending points will be (0, 1). (This parameter was the ending point for the purpose of interpolation.)</li>
</ul>
<h3>Methods</h3>
<ul>
<li><a href="#H3DU.BezierCurve_accel">accel</a><br>Finds an approximate acceleration vector at the specified u-coordinate of this curve.</li>
<li><a href="#H3DU.BezierCurve_arcLength">arcLength</a><br>Finds an approximate arc length (distance) between the start of this
curve and the point at the specified u-coordinate of this curve.</li>
<li><a href="#H3DU.BezierCurve_changeEnds">changeEnds</a><br>Creates a curve evaluator object for a curve that is generated using
the same formula as this one (and uses the same u-coordinates),
but has a different set of end points.</li>
<li><a href="#H3DU.BezierCurve_endPoints">endPoints</a><br>Returns the starting and ending u-coordinates of this curve.</li>
<li><a href="#H3DU.BezierCurve_evaluate">evaluate</a><br>Evaluates the curve function based on a point
in a Bézier curve.</li>
<li><a href="#H3DU.BezierCurve_fitRange">fitRange</a><br>Creates a curve evaluator object for a curve that follows the same
path as this one but has its u-coordinates remapped to fit the specified range.</li>
<li><a href="#H3DU.BezierCurve_getLength">getLength</a><br>Convenience method for getting the total length of this curve.</li>
<li><a href="#H3DU.BezierCurve_getPoints">getPoints</a><br>Gets an array of positions on the curve at fixed intervals
of u-coordinates.</li>
<li><a href="#H3DU.BezierCurve_jerk">jerk</a><br>Finds an approximate jerk vector at the specified u-coordinate of this curve.</li>
<li><a href="#H3DU.BezierCurve_normal">normal</a><br>Finds an approximate principal normal vector at the specified u-coordinate of this curve.</li>
<li><a href="#H3DU.BezierCurve_tangent">tangent</a><br>Convenience method for finding an approximate tangent vector of this curve at the specified u-coordinate.</li>
<li><a href="#H3DU.BezierCurve_toArcLengthParam">toArcLengthParam</a><br>Creates a curve evaluator object for a curve that follows the same
path as this one but has its u-coordinates remapped to
an <i>arc length parameterization</i>.</li>
<li><a href="#H3DU.BezierCurve_velocity">velocity</a><br>Finds an approximate velocity vector at the specified u-coordinate of this curve.</li>
</ul>
<p><a name='H3DU.BezierCurve_accel'></a></p>
<h3>H3DU.BezierCurve#accel(u)</h3>
<p>Finds an approximate acceleration vector at the specified u-coordinate of this curve.
The implementation in <a href="H3DU.Curve.html">H3DU.Curve</a> calls the evaluator's <code>accel</code>
method if it implements it; otherwise, does a numerical differentiation using
the velocity vector.</p>
<p>The <b>acceleration</b> of a curve is a vector which is the second-order derivative of the curve's position at the specified coordinate. The vector returned by this method <i>should not</i> be "normalized" to a <a href="tutorial-glmath.html">unit vector</a>.</p>
<h4>Parameters</h4>
<ul>
<li><code>u</code> (Type: number)<br>u-coordinate of a point on the curve.</li>
</ul>
<h4>Return Value</h4>
<p>An array describing an acceleration vector. It should have at least as many
elements as the number of dimensions of the underlying curve. (Type: Array.<number>)</p>
<p><a name='H3DU.BezierCurve_arcLength'></a></p>
<h3>H3DU.BezierCurve#arcLength(u)</h3>
<p>Finds an approximate arc length (distance) between the start of this
curve and the point at the specified u-coordinate of this curve.
The implementation in <a href="H3DU.Curve.html">H3DU.Curve</a> calls the evaluator's <code>arcLength</code>
method if it implements it; otherwise, calculates a numerical integral using the velocity vector.</p>
<p>The <b>arc length</b> function returns a number; if the curve is "smooth", this is the integral, from the starting point to <code>u</code>, of the length of the velocity vector.</p>
<h4>Parameters</h4>
<ul>
<li><code>u</code> (Type: number)<br>u-coordinate of a point on the curve.</li>
</ul>
<h4>Return Value</h4>
<p>The approximate arc length of this curve at the specified u-coordinate. (Type: number)</p>
<p><a name='H3DU.BezierCurve_changeEnds'></a></p>
<h3>H3DU.BezierCurve#changeEnds(ep1, ep2)</h3>
<p>Creates a curve evaluator object for a curve that is generated using
the same formula as this one (and uses the same u-coordinates),
but has a different set of end points.
For example, this method can be used to shrink the path of a curve
from [0, π] to [0, π/8].</p>
<p>Note, however, that in general, shrinking
the range of a curve will not shrink the length of a curve
in the same proportion, unless the curve's path runs at
constant speed with respect to time. For example, shrinking the range of a curve
from [0, 1] to [0, 0.5] will not generally result in a curve that's exactly half as
long as the original curve.</p>
<h4>Parameters</h4>
<ul>
<li><code>ep1</code> (Type: number)<br>New start point of the curve.</li>
<li><code>ep2</code> (Type: number)<br>New end point of the curve.</li>
</ul>
<h4>Return Value</h4>
<p>Return value. (Type: <a href="H3DU.Curve.html">H3DU.Curve</a>)</p>
<p><a name='H3DU.BezierCurve_endPoints'></a></p>
<h3>H3DU.BezierCurve#endPoints()</h3>
<p>Returns the starting and ending u-coordinates of this curve.</p>
<h4>Return Value</h4>
<p>A two-element array. The first and second
elements are the starting and ending u-coordinates, respectively, of the curve. (Type: Array.<number>)</p>
<p><a name='H3DU.BezierCurve_evaluate'></a></p>
<h3>H3DU.BezierCurve#evaluate(u)</h3>
<p>Evaluates the curve function based on a point
in a Bézier curve.</p>
<h4>Parameters</h4>
<ul>
<li><code>u</code> (Type: number)<br>Point on the curve to evaluate (generally within the range given in the constructor).</li>
</ul>
<h4>Return Value</h4>
<p>An array of the result of
the evaluation. It will have as many elements as a control point, as specified in the constructor. (Type: Array.<number>)</p>
<h4>Example</h4>
<pre>// Generate 11 points forming the B&eacute;zier curve.
// Assumes the curve was created with u1=0 and u2=1 (the default).
var points=[];
for(var i=0;i<=10;i++) {
points.push(curve.evaluate(i/10.0));
}
</pre>
<p><a name='H3DU.BezierCurve_fitRange'></a></p>
<h3>H3DU.BezierCurve#fitRange(ep1, ep2)</h3>
<p>Creates a curve evaluator object for a curve that follows the same
path as this one but has its u-coordinates remapped to fit the specified range.
For example, this method can be used to shrink the range of u-coordinates
from [-π, π] to [0, 1] without shortening the path of the curve.
Here, -π now maps to 0, and π now maps to 1.</p>
<h4>Parameters</h4>
<ul>
<li><code>ep1</code> (Type: number)<br>New value to use as the start point of the curve.</li>
<li><code>ep2</code> (Type: number)<br>New value to use as the end point of the curve.</li>
</ul>
<h4>Return Value</h4>
<p>Return value. (Type: <a href="H3DU.Curve.html">H3DU.Curve</a>)</p>
<p><a name='H3DU.BezierCurve_getLength'></a></p>
<h3>H3DU.BezierCurve#getLength()</h3>
<p>Convenience method for getting the total length of this curve.</p>
<h4>Return Value</h4>
<p>The distance from the start of the curve to its end. (Type: number)</p>
<p><a name='H3DU.BezierCurve_getPoints'></a></p>
<h3>H3DU.BezierCurve#getPoints(count)</h3>
<p>Gets an array of positions on the curve at fixed intervals
of u-coordinates. Note that these positions will not generally be
evenly spaced along the curve unless the curve uses
an arc-length parameterization.</p>
<h4>Parameters</h4>
<ul>
<li><code>count</code> (Type: number)<br>Number of positions to generate. Throws an error if this number is 0. If this value is 1, returns an array containing the starting point of this curve.</li>
</ul>
<h4>Return Value</h4>
<p>An array of curve positions. The first
element will be the start of the curve. If "count" is 2 or greater, the last element
will be the end of the curve. (Type: Array.<Array.<number>>)</p>
<p><a name='H3DU.BezierCurve_jerk'></a></p>
<h3>H3DU.BezierCurve#jerk(u)</h3>
<p>Finds an approximate jerk vector at the specified u-coordinate of this curve.
The implementation in <a href="H3DU.Curve.html">H3DU.Curve</a> calls the evaluator's <code>jerk</code>
method if it implements it; otherwise, does a numerical differentiation using
the acceleration vector.</p>
<p>The <b>jerk</b> of a curve is a vector which is the third-order derivative of the curve's position at the specified coordinate. The vector returned by this method <i>should not</i> be "normalized" to a <a href="tutorial-glmath.html">unit vector</a>.</p>
<h4>Parameters</h4>
<ul>
<li><code>u</code> (Type: number)<br>u-coordinate of a point on the curve.</li>
</ul>
<h4>Return Value</h4>
<p>An array describing a jerk vector. It should have at least as many
elements as the number of dimensions of the underlying curve. (Type: Array.<number>)</p>
<p><a name='H3DU.BezierCurve_normal'></a></p>
<h3>H3DU.BezierCurve#normal(u)</h3>
<p>Finds an approximate principal normal vector at the specified u-coordinate of this curve.
The implementation in <a href="H3DU.Curve.html">H3DU.Curve</a> calls the evaluator's <code>normal</code>
method if it implements it; otherwise, does a numerical differentiation using the velocity vector.</p>
<p>The <b>principal normal</b> of a curve is the derivative of the "normalized" velocity
vector divided by that derivative's length. The normal returned by this method
<i>should</i> be "normalized" to a <a href="tutorial-glmath.html">unit vector</a>. (Compare with <a href="H3DU.Surface.html#H3DU.Surface_gradient">H3DU.Surface#gradient</a>.)</p>
<h4>Parameters</h4>
<ul>
<li><code>u</code> (Type: number)<br>u-coordinate of a point on the curve.</li>
</ul>
<h4>Return Value</h4>
<p>An array describing a normal vector. It should have at least as many
elements as the number of dimensions of the underlying curve. (Type: Array.<number>)</p>
<p><a name='H3DU.BezierCurve_tangent'></a></p>
<h3>H3DU.BezierCurve#tangent(u)</h3>
<p>Convenience method for finding an approximate tangent vector of this curve at the specified u-coordinate.
The <b>tangent vector</b> is the same as the velocity vector, but "normalized" to a unit vector.</p>
<h4>Parameters</h4>
<ul>
<li><code>u</code> (Type: number)<br>u-coordinate of a point on the curve.</li>
</ul>
<h4>Return Value</h4>
<p>An array describing a normal vector. It should have at least as many
elements as the number of dimensions of the underlying curve. (Type: Array.<number>)</p>
<p><a name='H3DU.BezierCurve_toArcLengthParam'></a></p>
<h3>H3DU.BezierCurve#toArcLengthParam()</h3>
<p>Creates a curve evaluator object for a curve that follows the same
path as this one but has its u-coordinates remapped to
an <i>arc length parameterization</i>. Arc length
parameterization allows for moving along a curve's path at a uniform
speed and for generating points which are spaced evenly along that
path -- both features are more difficult with most other kinds
of curve parameterization.</p>
<p>The <i>end points</i> of the curve (obtained by calling the <code>endPoints</code>
method) will be (0, N), where N is the distance to the end of the curve from its
start.</p>
<p>When converting to an arc length parameterization, the curve
should be continuous and have a speed greater than 0 at every
point on the curve. The arc length parameterization used in
this method is approximate.</p>
<h4>Return Value</h4>
<p>Return value. (Type: <a href="H3DU.Curve.html">H3DU.Curve</a>)</p>
<p><a name='H3DU.BezierCurve_velocity'></a></p>
<h3>H3DU.BezierCurve#velocity(u)</h3>
<p>Finds an approximate velocity vector at the specified u-coordinate of this curve.
The implementation in <a href="H3DU.Curve.html">H3DU.Curve</a> calls the evaluator's <code>velocity</code>
method if it implements it; otherwise, does a numerical differentiation using
the position (from the <code>evaluate</code> method).</p>
<p>The <b>velocity</b> of a curve is a vector which is the derivative of the curve's position at the specified coordinate. The vector returned by this method <i>should not</i> be "normalized" to a <a href="tutorial-glmath.html">unit vector</a>.</p>
<h4>Parameters</h4>
<ul>
<li><code>u</code> (Type: number)<br>u-coordinate of a point on the curve.</li>
</ul>
<h4>Return Value</h4>
<p>An array describing a velocity vector. It should have at least as many
elements as the number of dimensions of the underlying curve. (Type: Array.<number>)</p>
<p><a href="index.html">Back to documentation index.</a></p>
</div><nav id="navigation"><ul>
<li><a href="/">Back to start site.</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io">This site's repository (source code)</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io/issues">Post an issue or comment</a></ul>
<p>
<a href="//twitter.com/share">Share via Twitter</a>, <a href="//www.facebook.com/sharer/sharer.php" id="sharer">Share via Facebook</a>
</p>
</div>
<h3>Navigation</h3>
<ul>
<li><a href="DrawingToy.html">DrawingToy</a></li>
<li><a href="Epitrochoid.html">Epitrochoid</a></li>
<li><a href="H3DU.html">H3DU</a></li>
<li><a href="H3DU.BSplineCurve.html">H3DU.BSplineCurve</a></li>
<li><a href="H3DU.BSplineSurface.html">H3DU.BSplineSurface</a></li>
<li><a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a></li>
<li><a href="H3DU.Camera.html">H3DU.Camera</a></li>
<li><a href="H3DU.Curve.html">H3DU.Curve</a></li>
<li><a href="H3DU.CurveBuilder.html">H3DU.CurveBuilder</a></li>
<li><a href="H3DU.CurveTube.html">H3DU.CurveTube</a></li>
<li><a href="H3DU.GraphicsPath.html">H3DU.GraphicsPath</a></li>
<li><a href="H3DU.InputTracker.html">H3DU.InputTracker</a></li>
<li><a href="H3DU.MathUtil.html">H3DU.MathUtil</a></li>
<li><a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a></li>
<li><a href="H3DU.Meshes.html">H3DU.Meshes</a></li>
<li><a href="H3DU.PiecewiseCurve.html">H3DU.PiecewiseCurve</a></li>
<li><a href="H3DU.Shape.html">H3DU.Shape</a></li>
<li><a href="H3DU.ShapeGroup.html">H3DU.ShapeGroup</a></li>
<li><a href="H3DU.Surface.html">H3DU.Surface</a></li>
<li><a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a></li>
<li><a href="H3DU.TextFont.html">H3DU.TextFont</a></li>
<li><a href="H3DU.TextureAtlas.html">H3DU.TextureAtlas</a></li>
<li><a href="H3DU.Transform.html">H3DU.Transform</a></li>
<li><a href="Hypotrochoid.html">Hypotrochoid</a></li>
<li><a href="MatrixStack.html">MatrixStack</a></li>
<li><a href="Polyhedra.html">Polyhedra</a></li>
<li><a href="Promise.html">Promise</a></li>
<li><a href="Semantic.html">Semantic</a></li>
<li><a href="StarField.html">StarField</a></li>
<li><a href="Superellipsoid.html">Superellipsoid</a></li>
<li><a href="Supertoroid.html">Supertoroid</a></li>
<li><a href="SurfaceOfRevolution.html">SurfaceOfRevolution</a></li>
<li><a href="Trochoid.html">Trochoid</a></li>
<li><a href="curveCatacaustic.html">curveCatacaustic</a></li>
<li><a href="curveEvolute.html">curveEvolute</a></li>
<li><a href="curveInverse.html">curveInverse</a></li>
<li><a href="curveInvolute.html">curveInvolute</a></li>
<li><a href="curveOrthotomic.html">curveOrthotomic</a></li>
<li><a href="curvePedalCurve.html">curvePedalCurve</a></li>
<li><a href="curveRadialCurve.html">curveRadialCurve</a></li>
<li><a href="polarCurve.html">polarCurve</a></li>
<li><a href="ruledSurface.html">ruledSurface</a></li>
<li><a href="spiralCurve.html">spiralCurve</a></li>
</ul>
</nav>
</body></html>