|
@@ -10,15 +10,27 @@
|
|
|
<body>
|
|
|
<h1>[name]</h1>
|
|
|
|
|
|
- <div class="desc">Represents a spline.</div>
|
|
|
+ <div class="desc">
|
|
|
+ Class representing a [link:https://en.wikipedia.org/wiki/Spline_(mathematics) spline].<br /><br />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <h2>Examples</h2>
|
|
|
+ <div>
|
|
|
+ [example:webgl_lines_splines WebGL / lines / splines]<br />
|
|
|
+ [example:webgl_lines_dashed WebGL / lines / dashed]<br />
|
|
|
+ [example:software_sandbox Software / sandbox]<br />
|
|
|
+ [example:canvas_lines_dashed Canvas / lines / dashed]
|
|
|
+ </div>
|
|
|
|
|
|
|
|
|
<h2>Constructor</h2>
|
|
|
|
|
|
-
|
|
|
<h3>[name]( [page:Array points] )</h3>
|
|
|
|
|
|
- <div>Initialises the spline with *points*, which are the places through which the spline will go.</div>
|
|
|
+ <div>
|
|
|
+ Initialises the spline with [page:Array points], which are the [page:Vector3 Vector3s]
|
|
|
+ through which the spline will pass.
|
|
|
+ </div>
|
|
|
|
|
|
|
|
|
<h2>Properties</h2>
|
|
@@ -28,39 +40,59 @@
|
|
|
|
|
|
<h2>Methods</h2>
|
|
|
|
|
|
- <h3>[method:null initFromArray]( [page:Array a] )</h3>
|
|
|
+ <h3>[method:Array getControlPointsArray]( )</h3>
|
|
|
<div>
|
|
|
- a — array of triplets containing x, y, z coordinates<br />
|
|
|
- </div>
|
|
|
- <div>Initialises using the data in the array as a series of points. Each value in *a* must be another array with three values, where a[n] is v, the value for the *nth* point, and v[0], v[1] and v[2] are the x, y and z coordinates of that point n, respectively.
|
|
|
+ Returns an array with triplets of [ x, y, z ] coordinates that correspond to the
|
|
|
+ current control points.
|
|
|
</div>
|
|
|
|
|
|
<h3>[method:Vector3 getPoint]( [page:Integer k] )</h3>
|
|
|
<div>
|
|
|
- k — point index
|
|
|
- </div>
|
|
|
- <div>Return the interpolated point at *k*.</div>
|
|
|
+ [page:Integer k] — point index<br /><br />
|
|
|
|
|
|
- <h3>[method:Array getControlPointsArray]( )</h3>
|
|
|
- <div>Returns an array with triplets of x, y, z coordinates that correspond to the current control points.
|
|
|
+ Return the interpolated point at [page:Integer k].
|
|
|
</div>
|
|
|
|
|
|
<h3>[method:Object getLength]( [page:Integer nSubDivisions] )</h3>
|
|
|
<div>
|
|
|
- nSubDivisions — number of subdivisions between control points. Default is *100*.
|
|
|
+ [page:Integer nSubDivisions] — number of subdivisions between control points. Default is *100*.<br /><br />
|
|
|
+
|
|
|
+
|
|
|
+ Returns an object with the two properties. The property <strong>[page:Number total]</strong> contains
|
|
|
+ the length of the spline when using [page:Integer nSubDivisions]. The property [page:Array chunkLength]
|
|
|
+ contains an array with the total length from the beginning of the spline to the end of that chunk.
|
|
|
</div>
|
|
|
+
|
|
|
+ <h3>[method:null initFromArray]( [page:Array a] )</h3>
|
|
|
<div>
|
|
|
- Returns an object with the two properties. The property .<strong>[page:Number total]</strong> contains
|
|
|
- the length of the spline when using nSubDivisions. The property .[page:Array chunkLength]
|
|
|
- contains an array with the total length from the beginning of the spline to the end of that chunk.
|
|
|
+ [page:Array a] — array of the form
|
|
|
+ <code>
|
|
|
+ var a [ [x1, y1, z1], [x2, y2, z2], ... ];
|
|
|
+ </code>
|
|
|
+ from which to initialise the points array.<br /><br />
|
|
|
+
|
|
|
+ Initialises using the data in the array as a series of points. Each value in *a* must
|
|
|
+ be another array with three values, where a[n] is v, the value for the *nth* point,
|
|
|
+ and v[0], v[1] and v[2] are the x, y and z coordinates of that point n, respectively.
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 interpolate]( p0, p1, p2, p3, t, t2, t3 )</h3>
|
|
|
+ <div>
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
<h3>[method:null reparametrizeByArcLength]( [page:Float samplingCoef] )</h3>
|
|
|
<div>
|
|
|
- samplingCoef — how many intermediate values to use between spline points
|
|
|
+ [page:Float samplingCoef] — how many intermediate values to use between spline points<br /><br />
|
|
|
+
|
|
|
+ Modifies the spline so that it looks similar to the original but has its points distributed
|
|
|
+ in such way that moving along the spline it's done at a more or less constant speed.
|
|
|
+ The points should also appear more uniformly spread along the curve.
|
|
|
+ This is done by resampling the original spline, with the density of sampling controlled by [page:Float samplingCoef].
|
|
|
+ Here it's interesting to note that denser sampling is not necessarily better:
|
|
|
+ if sampling is too high, you may get weird kinks in curvature.
|
|
|
</div>
|
|
|
- <div>Modifies the spline so that it looks similar to the original but has its points distributed in such way that moving along the spline it's done at a more or less constant speed. The points should also appear more uniformly spread along the curve.</div>
|
|
|
- <div>This is done by resampling the original spline, with the density of sampling controlled by *samplingCoef*. Here it's interesting to note that denser sampling is not necessarily better: if sampling is too high, you may get weird kinks in curvature.</div>
|
|
|
+
|
|
|
|
|
|
<h2>Source</h2>
|
|
|
|