Class Spline

Represents a spline.

see

src/math/Spline.js

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(points: SplineControlPoint[]): Spline

Initialises the spline with points, which are the places through which the spline will go.

Parameters

Returns

Spline

Properties

public points: SplineControlPoint[]

Methods

public getControlPointsArray(): Array<number[]>

Returns an array with triplets of x, y, z coordinates that correspond to the current control points.

Returns

Array<number[]>

public getLength(nSubDivisions?: number): { chunks: number[]; total: number; }

Returns the length of the spline when using nSubDivisions.

Parameters

  • nSubDivisions?: number optional

    number of subdivisions between control points. Default is 100.

Returns

{ chunks: number[]; total: number; }

public getPoint(k: number): SplineControlPoint

Return the interpolated point at k.

Parameters

  • k: number

    point index

Returns

SplineControlPoint

public initFromArray(a: Array<number[]>)

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.

Parameters

  • a: Array<number[]>

    array of triplets containing x, y, z coordinates

public reparametrizeByArcLength(samplingCoef: number)

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

Parameters

  • samplingCoef: number

    how many intermediate values to use between spline points